import com.vhly.util.DeviceInfo;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
import java.util.Vector;

final class MainThread extends cls_e
        implements Runnable, inf_m {

    private static int cK[];
    Spore sporeInstance;
    Display disp;
    private Image bufferImage;
    Graphics bufferGraphics;
    private boolean cM;
    RecordManager recordManager;
    private String language;
    private String forceLocale;
    private int cP;
    cls_f j;
    String strs[];
    String websiteURL;
    Vector fld_m_Vector;
    private Vector cQ;
    Vector n;
    Vector o;
    private Random cR;
    cls_b p;
    cls_b fld_q_b;
    cls_b r;
    cls_b s;
    cls_b t;
    cls_b u;
    cls_b fld_v_b;
    cls_b w;
    cls_b x;
    cls_ae y;
    boolean z;
    boolean A;
    boolean B;
    boolean C;
    boolean mgImpl_wap;
    boolean mgImpl_static;
    long F;
    int G;
    boolean H;
    boolean I;
    boolean J;
    cls_w K;
    cls_ab L;
    private int cS;
    int gameState;
    int N;
    int O;
    int P;
    int Q;
    int R;
    int S;
    int T;
    int U;
    int ai;
    int aj;
    int ak;
    int al;
    int am;
    int an;
    int ao;
    int ap;
    int aq;
    int ar;
    private int cT;
    int as;
    private int cU;
    cls_a at[];
    cls_a au[];
    cls_a av[];
    cls_a aw[];
    cls_a ax[];
    cls_a ay[];
    cls_a az[];
    cls_a aA[];
    Image sporeEALogo;
    Image consumerLogo;
    private Image imageResources[];
    Image img12;
    Image img76;
    Image img94;
    Image img93;
    Image img95;
    Image img25;
    Image img24;
    Image aK[];  // image 14.png 15.png 16.png TODO rename this array
    Image iceImages[];  // image 33.png 24.png 35.png TODO Rename to iceImages
    Image img78;
    Image img92;
    Image img91;
    Image img90;
    Image img36;
    boolean aR;
    boolean aS;
    private boolean cW;
    boolean aT;
    boolean aU;
    int aV;
    boolean aW;
    boolean aX;
    boolean aY;
    String aZ[][];
    String ba[][];
    private cls_a cX;
    cls_a bb;
    cls_a bc;
    cls_a bd;
    cls_a be;
    cls_a bf;
    cls_a bg;
    cls_a bh;
    Image bi[];
    String bj[];
    cls_k bk[];
    cls_u bl[];
    cls_u bm[];
    cls_u bn[];
    cls_u bo[];
    cls_u bp[];
    cls_u bq[];
    cls_u br[];
    cls_u bs[];
    cls_u bt[];
    cls_u bu[];
    cls_u bv[];
    cls_u bw[];
    cls_u bx[];
    cls_u by[];
    cls_u bz[];
    cls_u bA[];
    cls_u bB;
    cls_u bC;
    cls_u bD;
    cls_u bE;
    cls_u bF;
    cls_u bG;
    cls_u bH;
    cls_u bI;
    cls_u bJ;
    private cls_u cY;
    cls_u bK;
    private cls_u cZ;
    cls_u bL;
    cls_u bM[];
    cls_u bN;
    cls_u bO;
    private short da;
    private short db;
    static long bP;
    private long dc;
    private long dd;
    long bQ;
    private long de;
    long bR;
    long bS;
    long bT;
    long bU;
    long bV;
    long bW;
    long bX;
    long bY;
    long bZ;
    long ca;
    private long df;
    private long dg;
    long cb;
    int cc;
    char cd[][];
    int ce[];
    int cf[];
    int cg[];
    int ch[];
    cls_aa ci;
    cls_aa cj;
    cls_d ck;
    cls_d cl;
    cls_d cm;
    cls_d cn;
    private cls_d dh[];
    Vector co;
    Vector cp;
    Vector cq;
    private int di;
    private int dj;
    private int dk;
    private int dl;
    private int dm;
    private boolean dn;
    int cr;
    private cls_aa _flddo;
    private cls_aa dp;
    cls_aa cs;
    cls_aa ct;
    boolean cu;
    private boolean dq;
    String cv[][];
    int cw;
    private int dr[][];
    private int ds[][];
    short cx[];
    private cls_u dt[];
    int cy;
    int cz;
    private int du;
    private int dv;
    private boolean dw;
    private int dx;
    String cA;
    private int dy;
    String cB;
    int cC[][];
    byte cD[][];
    int cE[][];
    long cF;
    cls_u cG[];
    int cH[];
    boolean cI;
    private int dz;
    boolean enableTAF;
    private int dA;
    private int dB;
    private boolean dC;

    static int b(int i1) {
        return i1 << 8;
    }

    static int c(int i1) {
        return i1 >> 8;
    }

    static int d(int i1) {
        if ((i1) >> 8 >= 0)
            return i1 + 128;
        else
            return i1 - 128;
    }

    static int a(int i1, int j1) {
        return j1 * i1 >> 8;
    }

    static int e(int i1) {
        long l1;
        long l2 = (l1 = (long) i1 << 8) + 256L >> 1;
        for (i1 = 0; i1 < 8; i1++) {
            long l4 = l2;
            l2 = l2 + (l1 << 8) / l4 >> 1;
        }

        return (int) l2;
    }

    private static int t(int i1) {
        int j1 = 0;
        int k1 = 0x7fffffff;
        i1 = Math.abs(i1);
        int i2;
        for (int l1 = 0; l1 < 64 && (i2 = Math.abs(i1 - inf_m.ag[l1])) < k1; l1++) {
            k1 = i2;
            j1 = l1;
        }

        return j1;
    }

    static int f(int i1) {
        return inf_m.af[0xff & i1];
    }

    static int g(int i1) {
        return inf_m.af[0xff & 64 - i1];
    }

    static String a(String s1, String s2) {
        int i1;
        if ((i1 = s1.indexOf('%')) >= 0)
            return s1.substring(0, i1) + s2 + s1.substring(i1 + 1);
        else
            return s1;
    }

    static String a(String s1, String as1[]) {
        for (int i1 = 0; i1 < as1.length; i1++) {
            int j1;
            if ((j1 = s1.indexOf('%')) >= 0)
                s1 = s1.substring(0, j1) + as1[i1] + s1.substring(j1 + 1);
        }

        return s1;
    }

    static int a(cls_aa aa1, cls_aa aa2) {
        int i1 = aa1.a;
        int iaa1 = aa1.b;
        int j1 = aa2.a;
        int iaa2 = aa2.b;
        int k1;
        if ((k1 = Math.abs(i1 - j1)) == 0) {
            if (iaa2 > iaa1)
                return 64;
            return iaa2 >= iaa1 ? 0 : 192;
        }
        int l1;
        int i2 = Math.abs(iaa1 - iaa2);
        l1 = k1;
        k1 = t((i2 << 8) / l1);
        if (j1 >= i1 && iaa2 <= iaa1)
            k1 = 256 - k1;
        else if (j1 < i1 && iaa2 <= iaa1)
            k1 += 128;
        else if (j1 < i1 && iaa2 > iaa1)
            k1 = 128 - k1;
        return k1 & 0xff;
    }

    private static int b(int i1, int j1) {
//        int k1;
        i1 = ((i1) >> 8) * ((i1) >> 8);
        j1 = ((j1) >> 8) * ((j1) >> 8);
        return e(i1 += j1);
    }

    private static int c(int i1, int j1) {
        if (i1 != 0) {
//            int k1 = j1;
            int k1;
            k1 = t((j1 << 8) / i1);
            if (i1 > 0 && j1 <= 0)
                k1 = 256 - k1;
            else if (i1 < 0 && j1 <= 0)
                k1 += 128;
            else if (i1 < 0 && j1 > 0)
                k1 = 128 - k1;
            return 0xff & k1;
        }
        return j1 >= 0 ? 64 : 192;
    }

    static void a(cls_d d1, cls_d d2, int i1, int j1, int k1) {
        int l1;
        int i2;
        int j2;
        int k2;
        int i5;
        if (d1.y && d2.y)
            return;
        d1.y = true;
        d2.y = true;
        l1 = d1.p.a;
        i2 = d1.p.b;
        j2 = d2.p.a;
        k2 = d2.p.b;
        i1 = e(i1);
        if ((i1) != 0) {
//            int k3;
            int j4;
            i5 = (j1) << 8;
            j4 = i1;
//            k3 = i5;
            j1 = (i5 << 8) / j4;
        } else {
            j1 = 0;
        }
//        if(i1 == 0) goto _L2; else goto _L1
//_L1:
//        int k4;
//        int j5;
//        int l3;
//        j5 = (l3 = k1) << 8;
//        k4 = i1;
//        l3 = j5;
//        (j5 << 8) / k4;
//          goto _L3
//_L2:
//        false;
//_L3:
//        JVM INSTR dup ;
//        i1;
//        JVM INSTR ineg ;
//        k1;

        if (i1 != 0) {
            int k4;
            int j5;
            j5 = (k1) << 8;
            k4 = i1;
            i1 = (j5 << 8) / k4;
        } else {
            i1 = 0;
        }
        k1 = -i1;

        int l2 = j1;
        int l4 = j1;
        int i4 = l1;
        int i3 = (l4 * i4 >> 8) + ((i1) * (i2) >> 8);
        l4 = j1;
        i4 = j2;
        int j3 = (l4 * i4 >> 8) + ((i1) * (k2) >> 8);
        l4 = k1;
        i4 = l1;
        i2 = (l4 * i4 >> 8) + ((l2) * (i2) >> 8);
        l4 = k1;
        i4 = j2;
        k2 = (l4 * i4 >> 8) + ((l2) * (k2) >> 8);
        l4 = j1;
        i4 = j3;
        l1 = (l4 * i4 >> 8) + ((k1) * (i2) >> 8);
        l4 = i1;
        i4 = j3;
        i2 = (l4 * i4 >> 8) + ((l2) * (i2) >> 8);
        l4 = j1;
        i4 = i3;
        j2 = (l4 * i4 >> 8) + ((k1) * (k2) >> 8);
        l4 = i1;
        i4 = i3;
        k2 = (l4 * i4 >> 8) + ((l2) * (k2) >> 8);
        i1 = (d1.B * d1.C) << 8;
        int k5 = j1 = (d2.B * d2.C) << 8;
        l4 = i1;
        k1 = (k5 << 8) / l4;
        l4 = j1;
        i1 = (i1 << 8) / l4;
        l4 = k1;
        i4 = l1;
        l1 = l4 * i4 >> 8;
        l4 = k1;
        i4 = i2;
        i2 = l4 * i4 >> 8;
        l4 = i1;
        i4 = j2;
        j2 = l4 * i4 >> 8;
        l4 = i1;
        i4 = k2;
        k2 = l4 * i4 >> 8;
        d1.l = c(l1, i2);
        d1.d = b(l1, i2);
        if (d1.d < 2)
            d1.d = 2;
        else if (d1.d > 5120)
            d1.d = 5120;
        d2.l = c(j2, k2);
        d2.d = b(j2, k2);
        if (d2.d < 2)
            d2.d = 2;
        else if (d2.d > 5120)
            d2.d = 5120;
        i1 = (d1.E + d2.E >> 1) + 1;
        k1 = d1.o.a + d2.o.a >> 1;
        l1 = d1.o.b + d2.o.b >> 1;
        j1 = a(d1.o, d2.o);
        d2.o.a = k1 + i1 * g(j1);
        d2.o.b = l1 + i1 * f(j1);
        j1 += 128;
        d1.o.a = k1 + i1 * g(j1);
        d1.o.b = l1 + i1 * f(j1);
        return;
    }

    private static boolean a(cls_d d1, cls_d d2, int i1) {
        return d1.s == i1 || d2.s == i1;
    }

    /**
     * load /"s1".png s1 is index
     *
     * @param s1 image index
     * @return image file content
     */
    private static byte[] loadImageContent(String s1) {
        InputStream inputstream = Spore.mainThreadImpl.sporeInstance.getClass().getResourceAsStream("/" + s1 + ".png");
        int i1;
        try {
            i1 = 0;
            // calc inputstream resource length
            while (inputstream.read() != -1) {
                i1++;
            }
            inputstream = Spore.mainThreadImpl.sporeInstance.getClass().getResourceAsStream("/" + s1 + ".png");
            byte[] bs1 = new byte[i1];
            int j1 = 0;
            // read inputstream resource content to bs1 buffer.
            while (j1 < i1) {
                j1 += inputstream.read(bs1, j1, i1 - j1);
            }
            return bs1;
        } catch (Exception ex) {

        }
        return null;
    }

    private static int d(int i1, int j1) {
        int k1 = 1;
        for (int l1 = 0; l1 < j1; l1++)
            k1 *= i1;

        return k1;
    }

    static Image loadUnencodeImage(int i1) {
        Image image = null;
        for (int j1 = 0; j1 < 10 && image == null; j1++) {
            try {
                System.gc();
                image = Image.createImage("/" + i1 + ".png");
                continue;
            }
            catch (Throwable _ex) {
                System.gc();
            }
            try {
                Thread.sleep(100L);
            }
            catch (Exception _ex) {
            }
        }

        if (image == null)
            image = Image.createImage(1, 1);
        return image;
    }

    static Image a(int i1, int ai1[]) {
        byte[] bi1 = loadImageContent(Integer.toString(i1));  // loadImageResource /'i1'.png

        int j1 = 0;
        int k1 = 0;
        do {
            if (k1 >= bi1.length - 4)
                break;
            // 80 : P
            // 76 : L
            // 84 : T
            // 69 : E
            // find 'PLTE' flag in content(png). 
            if (bi1[k1] == 80 && bi1[k1 + 1] == 76 && bi1[k1 + 2] == 84 && bi1[k1 + 3] == 69) {
                j1 = k1 - 4;
                break;
            }
            k1++;
        } while (true);
        // j1 is PLTE Prev 4
        k1 = (bi1[j1] << 24) + (bi1[j1 + 1] << 16) + (bi1[j1 + 2] << 8) + bi1[j1 + 3];
        j1 += 8;
        int l1 = (j1) + k1;
        int i2 = Math.min(ai1.length, k1 / 3);
        for (int j2 = 0; j2 < i2; j2++) {
            int i3 = j1 + j2 * 3;
            int k3 = ai1[j2];
            bi1[i3++] = (byte) (k3 >> 16);
            bi1[i3++] = (byte) (k3 >> 8);
            bi1[i3] = (byte) k3;
        }

        k1 += 4;
        j1 = j1 - 4;
        i2 = -1;
        if (cK == null) {
            cK = new int[256];
            for (int j3 = 0; j3 < 256; j3++) {
                int k2 = j3;
                for (int l3 = 8; l3 > 0; l3--)
                    if ((k2 & 1) == 1)
                        k2 = k2 >>> 1 ^ 0xedb88320;
                    else
                        k2 >>>= 1;

                cK[j3] = k2;
            }

        }
        while (k1-- != 0)
            i2 = cK[(i2 ^ bi1[j1++]) & 0xff] ^ i2 >>> 8;
        int l2 = ~i2;
        bi1[l1] = (byte) (l2 >> 24);
        bi1[l1 + 1] = (byte) (l2 >> 16);
        bi1[l1 + 2] = (byte) (l2 >> 8);
        bi1[l1 + 3] = (byte) l2;
        Image image = null;
        for (int i4 = 0; i4 < 10 && image == null; i4++) {
            try {
                System.gc();
                image = Image.createImage(bi1, 0, bi1.length);
                continue;
            }
            catch (Throwable _ex) {
                System.gc();
            }
            try {
                Thread.sleep(100L);
            }
            catch (Exception _ex) {
            }
        }

        if (image == null)
            image = Image.createImage(1, 1);
        return image;
    }

    MainThread(Spore spore) {
        strs = new String[292];
        at = new cls_a[3];
        au = new cls_a[3];
        av = new cls_a[3];
        aw = new cls_a[3];
        ax = new cls_a[3];
        ay = new cls_a[3];
        az = new cls_a[3];
        aA = new cls_a[3];
        imageResources = new Image[190];
        aK = new Image[3];
        iceImages = new Image[3];
        bk = new cls_k[7];
        bl = new cls_u[10];
        bm = new cls_u[10];
        bn = new cls_u[10];
        bo = new cls_u[10];
        bp = new cls_u[10];
        bq = new cls_u[10];
        br = new cls_u[10];
        bs = new cls_u[10];
        bt = new cls_u[10];
        bu = new cls_u[10];
        bv = new cls_u[10];
        bw = new cls_u[10];
        bx = new cls_u[10];
        by = new cls_u[10];
        bz = new cls_u[10];
        bA = new cls_u[10];
        bM = new cls_u[3];
        du = -1;
        dv = -1;
        cG = new cls_u[7];
        cH = new int[3];
        int ai1[] = new int[6];
        ai1[0] = 0x4c2567;
        ai1[1] = 0x3d1203;
        ai1[2] = 0x291e58;
        ai1[3] = 123;
        ai1[4] = 0x244604;
        ai1[5] = 0xac894c;
        sporeInstance = spore;
        cR = new Random();
        A = true;
        cS = 0;
        gameState = 1;
        bP = System.currentTimeMillis();
        bQ = System.currentTimeMillis();
        ci = new cls_aa(0, 0);
        R = -1;
        disp = Spore.disp;
        cW = false;
        z = true;
        L = new cls_ab(this);
        fld_m_Vector = new Vector();
        cQ = new Vector();
        o = new Vector();
        n = new Vector();
        cs = new cls_aa(0, 0);
        ct = new cls_aa(0, 0);
        loadLanguageData("/lang2.data");
    }

    final String a(long l1) {
        int i1 = (int) ((l1 = Math.max(0L, l1)) / 60000L);
        l1 = (int) ((l1 - (long) (i1 * 60000)) / 1000L);
        String s1 = Integer.toString(i1) + strs[256];
        if (l1 < 10)
            s1 = s1 + "0";
        return s1 + Integer.toString((int) l1);
    }

    final void i(int i1) {
        N = gameState;
        gameState = 0;
        dj = cT = i1;
        di = -1;
        dg = System.currentTimeMillis();
        if (i1 != 142) {
            cP = -1;
            if (i1 != 28)
                L.d();
        }
        cs.a = 0;
        dm = 166;
    }

    final void a() {
        if (gameState != 0)
            return;
        if (System.currentTimeMillis() > dg + 250L) {
//            int i1;
            try {
                dl = (dm * (((++di) << 8) / (dj + dk))) >> 8;
            }
            catch (Exception _ex) {
            }
            if (dl > dm)
                dl = dm;
            a(bufferGraphics, 2048);
            repaint();
            serviceRepaints();
            return;
        } else {
            dj--;
            return;
        }
    }

    final void b() {
        int i1 = dj + dk;
        if (di > i1)
            System.out.println("loading bar too short: is " + dj + "(" + dk + "), should be at " + di);
        else if (di < i1)
            System.out.println("loading bar too long: is " + dj + "(" + dk + "), should be at " + di);
        gameState = N;
        dk = 0;
        super.fld_e_int = super.keyStats = 0;
    }

    private void loadLanguageData(String s1) {
        InputStream inputstream = null;
        try {
            inputstream = getClass().getResourceAsStream(s1);
            int is1 = convertShort((inputstream).read(), inputstream.read());
            strs = new String[is1];
            for (int i1 = 0; i1 < is1; i1++) {
                int j1 = convertShort(inputstream.read(), inputstream.read());
                byte abyte0[] = new byte[j1];
                inputstream.read(abyte0, 0, abyte0.length);
                strs[i1] = new String(abyte0, "UTF-8");
            }

        }
        catch (IOException _ex) {
            _ex.printStackTrace();
        }
        finally {
            if (inputstream != null)
                try {
                    inputstream.close();
                }
                catch (IOException _ex) {
                }
        }
    }

    private static int convertShort(int i1, int j1) {
        if (j1 < 0)
            j1 += 256;
        j1 = (j1 <<= 8) + i1;
        if (i1 < 0)
            j1 += 256;
        return j1;
    }

    final void c() {
        U = (T / 3) % 6;
        boolean aflag[] = new boolean[190];
        try {
            InputStream inputstream = sporeInstance.getClass().getResourceAsStream("/" + Integer.toString(1 + T % 18) + ".bin");
            DataInputStream datainputstream = new DataInputStream(inputstream);
            cz = (datainputstream.readShort() * 100) / 100;
            cy = (datainputstream.readShort() * 100) / 100;
            du = datainputstream.readShort();
            dw = datainputstream.readBoolean();
            dx = datainputstream.readInt();
            if (du != -1)
                aflag[du] = true;
            a();
            dv = datainputstream.readShort();
            datainputstream.readBoolean();
            if (dv != -1)
                aflag[dv] = true;
            short word0;
            int ai1[][] = new int[word0 = datainputstream.readShort()][];
            dt = new cls_u[word0];
            cls_a a1 = null;
            cls_a a2 = null;
            for (int i1 = 0; i1 < word0; i1++) {
                short word2 = datainputstream.readShort();
                short word3 = datainputstream.readShort();
                int i3 = (datainputstream.readShort() * 100) / 100;
                int l3 = (datainputstream.readShort() * 100) / 100;
                if (word2 != -1)
                    aflag[word2] = true;
                ai1[i1] = (new int[]{
                        word2, i3, l3
                });
                if (word3 != 0 && R == 0)
                    switch (word2) {
                        default:
                            break;

                        case 23: // '\027'
                            if (a1 == null)
                                a1 = new cls_a(150, 71);
                            dt[i1] = new cls_u(a1);
                            dt[i1].j = 3;
                            break;

                        case 71: // 'G'
                            if (a2 == null)
                                a2 = new cls_a(151, 72);
                            dt[i1] = new cls_u(a2);
                            dt[i1].j = 3;
                            break;
                    }
            }

            a();
            short word1;
            int ai3[][] = new int[word1 = datainputstream.readShort()][];
            for (int j1 = 0; j1 < word1; j1++) {
                short word4 = datainputstream.readShort();
                datainputstream.readShort();
                short word5 = datainputstream.readShort();
                short word6 = datainputstream.readShort();
                if (word4 != -1)
                    aflag[word4] = true;
                ai3[j1] = (new int[]{
                        word4, word5, word6
                });
            }

            a();
            for (int k1 = 0; k1 < 190; k1++)
                if (imageResources[k1] != null && !aflag[k1])
                    imageResources[k1] = null;

            for (int l1 = 0; l1 < 190; l1++) {
                if (imageResources[l1] == null && aflag[l1]) {
                    imageResources[l1] = loadUnencodeImage(l1);
                }
            }
            a();
            dr = new int[word0][];
            for (int i2 = 0; i2 < word0; i2++) {
                if (ai1[i2] == null)
                    continue;
                int k2 = ai1[i2][0];
                int j3 = 0;
                int i4 = 0;
                if (k2 != -1) {
                    j3 = imageResources[k2].getWidth();
                    i4 = imageResources[k2].getHeight();
                }
                dr[i2] = (new int[]{
                        k2, ai1[i2][1], ai1[i2][2], j3, i4
                });
            }

            ds = new int[word1][];
            for (int j2 = 0; j2 < word1; j2++) {
                int l2 = ai3[j2][0];
                int k3 = 0;
                int j4 = 0;
                if (l2 != -1) {
                    k3 = imageResources[l2].getWidth();
                    j4 = imageResources[l2].getHeight();
                }
                ds[j2] = (new int[]{
                        ai3[j2][0], ai3[j2][1], ai3[j2][2], k3, j4
                });
            }

            a();
        }
        catch (IOException ioexception) {
            sporeInstance.notifyDestroyed();
        }
        int ai2[] = r(27 + U);
        K.a(ai2);
        a();
    }

    final void a(cls_d d1, int i1, int j1) {
        switch (i1) {
            default:
                break;

            case 0:
            case 6:
                cQ.removeAllElements();
                for (int k1 = 0; k1 < 10; k1++) {
                    for (int i3 = 0; i3 < 12; i3++)
                        f(1 << i3, k1);

                }

                bC = null;
                if (i1 == 0)
                    break;
                // fall through

            case 1:
                for (int l1 = 0; l1 < 12; l1++)
                    if ((d1.H & 1 << l1) != 0)
                        g(1 << l1, d1.f);

                cQ.addElement(d1);
                return;

            case 4:
                for (int i2 = 0; i2 < cQ.size(); i2++) {
                    cls_d d2;
                    if (!(d2 = (cls_d) cQ.elementAt(i2)).equals(d1) && d2.f == d1.f && (d2.H & j1) != 0)
                        return;
                }

                f(j1, d1.f);
                return;

            case 5:
                for (int j2 = 0; j2 < cQ.size(); j2++) {
                    cls_d d3 = (cls_d) cQ.elementAt(j2);
                    if ((d3).r == d1.r)
                        cQ.removeElementAt(j2--);
                }

                // fall through
                // TODO Check need breat ?

            case 3:
                cQ.removeElement(d1);
                if (!cQ.isEmpty()) {
                    int k2 = 0;
                    for (int j3 = 0; j3 < cQ.size(); j3++) {
                        cls_d di1 = (cls_d) cQ.elementAt(j3);
                        for (j1 = 0; j1 < 12; j1++)
                            if (di1.f == d1.f && (di1.H & 1 << j1) != 0)
                                k2 |= 1 << j1;

                    }

                    for (int k3 = 0; k3 < 12; k3++)
                        if ((k2 & 1 << k3) == 0)
                            f(1 << k3, d1.f);

                    return;
                }
                for (int l2 = 0; l2 < 12; l2++)
                    if ((d1.H & 1 << l2) != 0)
                        f(1 << l2, d1.f);

                return;

            case 2:
                g(j1, d1.f);
                return;

            case 7:
                if (bC == null)
                    bC = new cls_u(167, 66);
                break;
        }
    }

    private void f(int i1, int j1) {
        switch (i1) {
            case 1:
                bl[j1] = null;
                return;

            case 2:
                bm[j1] = null;
                return;

            case 4:
                bn[j1] = null;
                return;

            case 8:
                bo[j1] = null;
                bp[j1] = null;
                return;

            case 16:
                bq[j1] = null;
                return;

            case 32:
                br[j1] = null;
                bs[j1] = null;
                bt[j1] = null;
                bu[j1] = null;
                return;

            case 64:
                bv[j1] = null;
                return;

            case 128:
                bw[j1] = null;
                bx[j1] = null;
                return;

            case 256:
                by[j1] = null;
                for (i1 = 0; i1 < 10 && by[i1] == null; i1++)
                    if (i1 == 9)
                        bH = null;

                return;

            case 1024:
                bz[j1] = null;
                return;

            case 2048:
                bA[j1] = null;
                break;
        }
    }

    private void g(int i1, int j1) {
        int ai1[] = cE[j1];
        switch (i1) {
            default:
                break;

            case 1:
                if (bl[j1] == null) {
                    bl[j1] = new cls_u(133, 39, ai1);
                    bl[j1].j = 1;
                    bl[j1].l = 100;
                    return;
                }
                break;

            case 2:
                if (bm[j1] == null) {
                    bm[j1] = new cls_u(132, 41, ai1);
                    bm[j1].j = 3;
                    bm[j1].l = 250;
                    return;
                }
                break;

            case 4:
                if (bn[j1] == null) {
                    bn[j1] = new cls_u(131, 45, ai1);
                    bn[j1].j = 3;
                    bn[j1].l = 250;
                    return;
                }
                break;

            case 8:
                if (bp[j1] == null) {
                    bo[j1] = new cls_u(144, 53, ai1);
                    bp[j1] = new cls_u(145, 54, ai1);
                    return;
                }
                break;

            case 16:
                if (bq[j1] == null) {
                    bq[j1] = new cls_u(137, 46, ai1);
                    return;
                }
                break;

            case 32:
                if (br[j1] == null) {
                    br[j1] = new cls_u(140, 51, ai1);
                    bs[j1] = new cls_u(143, 50, ai1);
                    bt[j1] = new cls_u(142, 49, ai1);
                    bu[j1] = new cls_u(141, 52, ai1);
                    return;
                }
                break;

            case 64:
                if (bv[j1] == null) {
                    bv[j1] = new cls_u(130, 40, ai1);
                    bv[j1].j = 3;
                    bv[j1].l = 250;
                    return;
                }
                break;

            case 128:
                if (bw[j1] == null) {
                    bw[j1] = new cls_u(139, 47, ai1);
                    bw[j1].j = 3;
                    bw[j1].l = 250;
                    bx[j1] = new cls_u(138, 48, ai1);
                    bx[j1].j = 3;
                    bx[j1].l = 250;
                    return;
                }
                break;

            case 256:
                if (by[j1] != null)
                    break;
                by[j1] = new cls_u(135, 42, ai1);
                by[j1].j = 0;
                by[j1].l = 250;
                if (bH == null) {
                    bH = new cls_u(168, 69);
                    bH.l = 150;
                    return;
                }
                break;

            case 1024:
                if (bz[j1] == null) {
                    bz[j1] = new cls_u(134, 44, ai1);
                    bz[j1].j = 3;
                    bz[j1].l = 250;
                    return;
                }
                break;

            case 2048:
                if (bA[j1] == null) {
                    bA[j1] = new cls_u(136, 43, ai1);
                    bA[j1].j = 3;
                    bA[j1].l = 250;
                }
                break;
        }
    }

    final void a(Graphics g1, cls_u u1, int i1, int j1, int k1) {
        int l1 = gameState != 8 ? P % 4 : 0;
        int i2 = l1;
        l1 = 192 + l1 * 16 & 0xff;
        int j2 = 4;
        do {
            int l2;
            int k2 = j1 + ((i1 * g(l1) + 128) >> 8);
            l2 = k1 + ((i1 * f(l1) + 128) >> 8);
            if (l1 > 0 && l1 < 128)
                l2 += u1.g >> 1;
            else if (l1 != 0 && l1 != 128)
                l2 -= u1.g >> 1;
            if (l1 > 64 && l1 < 192)
                k2 -= u1.f >> 1;
            else if (l1 != 64 && l1 != 192)
                k2 += u1.f >> 1;
            u1.a(g1, k2, l2, i2, 0, 3);
            l1 = l1 + 64 & 0xff;
            i2 += 4;
        } while (--j2 > 0);
    }

    final void a(Graphics g1, int i1, int j1, int k1, int l1) {
        int i2 = (i1 + k1 >> 1) + (j(5) - 2);
        int j2 = (j1 + l1 >> 1) + (j(5) - 2);
        int k2 = (i1 + i2 >> 1) + (j(5) - 2);
        int l2 = (j1 + j2 >> 1) + (j(5) - 2);
        int i3 = (i2 + k1 >> 1) + (j(5) - 2);
        int j3 = (j2 + l1 >> 1) + (j(5) - 2);
        g1.drawLine(i1, j1, k2, l2);
        g1.drawLine(k2, l2, i2, j2);
        g1.drawLine(i2, j2, i3, j3);
        g1.drawLine(i3, j3, k1, l1);
    }

    private void b(Graphics g1) {
//        int i1;
        int j2 = ((ci.a << 1) >> 1) >> 8;
        int k2 = ((ci.b << 1) >> 1) >> 8;
        if (du == -1) {
            g1.setColor(dx);
            g1.fillRect(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
        } else {
            Image image = imageResources[du];
            if (dw) {
                int i3 = image.getWidth();
                int k3 = image.getHeight();
                int l1;
                if ((l1 = -k2 % k3) > 0)
                    l1 -= k3;
                do {
                    int j1;
                    if ((j1 = -j2 % i3) > 0)
                        j1 -= i3;
                    do
                        g1.drawImage(image, j1, l1, 20);
                    while ((j1 += i3) < DeviceInfo.DEVICE_SCREEN_WIDTH);
                } while ((l1 += k3) < DeviceInfo.DEVICE_SCREEN_HEIGHT);
            } else {
                g1.drawImage(image, 0, 0, 20);
            }
        }
        while (j2 < 0) {
            j2 += cz;
        }
        while (k2 < 0) {
            k2 += cy;
        }
        j2 %= cz;
        k2 %= cy;
        for (int l2 = 0; l2 < dr.length; l2++) {
            int ai1[];
            int k1 = h(((((ai1 = dr[l2])[1] << 1) >> 1) - j2) + 88, cz);
            int i2 = h((((ai1[2] << 1) >> 1) - k2) + 104, cy);
            if (k1 <= -ai1[3] || k1 >= DeviceInfo.DEVICE_SCREEN_WIDTH || i2 <= -ai1[4] || i2 >= DeviceInfo.DEVICE_SCREEN_HEIGHT)
                continue;
            cls_u u1 = dt[l2];
            int j3;
            if ((j3 = ai1[0]) != -1)
                g1.drawImage(imageResources[j3], k1, i2, 20);
            if (u1 == null)
                continue;
            if (u1.m < bR)
                if (u1.o) {
                    u1.a();
                    if (u1.b == 0 && u1.k == -1) {
                        u1.b = 1;
                        u1.m = bR + 10000L;
                        u1.o = false;
                    } else {
                        u1.m = bR + 150L;
                    }
                } else if (u1.b == 1) {
                    u1.b = 0;
                    u1.m = bR + 150L;
                } else if (u1.b == 0 && j(75) == 0) {
                    u1.b = 1;
                    u1.m = bR + 150L;
                }
            u1.a(g1, k1, i2, u1.b, 0, 20);
        }

    }

    private static int h(int i1, int j1) {
        if (i1 < -(j1 >> 1))
            i1 += j1;
        else if (i1 > j1 >> 1)
            i1 -= j1;
        return i1;
    }

    final void a(Graphics g1, int i1) {
        g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
        if ((i1 & 2) != 0)
            b(g1);
        else if ((i1 & 0x200000) != 0) {
            g1.setColor(0);
            g1.fillRect(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
        } else if ((i1 & 0x100000) != 0) {
            Graphics g2 = g1;
            cls_f f1 = j;
            g2.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            g2.drawImage(f1.img40, 0, 0, 20);
        }
        if ((i1 & 0x2000) != 0) {
            Graphics g3 = g1;
            MainThread ac1 = this;
            b(g3);
            int l1 = c(ac1.cj.a);
            int l2 = c(ac1.cj.b);
            g3.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            g3.setColor(0);
            g3.fillRect(0, 104 - (ac1.p.l + 20 >> 1), DeviceInfo.DEVICE_SCREEN_WIDTH, ac1.p.l + 20);
            int k3 = cls_b.c(ac1.strs[154]);
            ac1.w.a(g3, ac1.strs[154], l1 + (DeviceInfo.DEVICE_SCREEN_WIDTH - k3 >> 1), l2, 6);
        } else if ((i1 & 0x8000) != 0) {
            Graphics g4 = g1;
            MainThread ac2 = this;
            g4.drawImage(ac2.img78, 0, 0, 20);
            String s1 = cls_b.a(ac2.strs[ac2.cx[ac2.an]]);
            int i3;
            int l3;
            i3 = (l3 = (204 - ac2.p.n) / ac2.u.n) * ac2.u.n;
            int k4 = 104 - (4 + ac2.u.n >> 1);
            if (!ac2.dC) {
                int k5 = ac2.u.e(s1);
                if (k4 + (k5 >> 1) > 204 - ac2.p.n)
                    ac2.dB = (k5 / ac2.u.n - l3) + 1;
                else
                    ac2.dB = 1;
                ac2.dC = true;
            }
            if (ac2.dB > 1) {
                g4.setClip(0, 4, DeviceInfo.DEVICE_SCREEN_WIDTH, i3);
                ac2.u.a(g4, s1, 84, 4 - ac2.dA * ac2.u.n, 17);
                int l7 = i3;
//                byte byte1 = 4;
                Graphics g11 = g4;
                MainThread ac9 = ac2;
                l7 -= 8;
                g11.setColor(0xffffff);
                g11.drawRect(168, 8, 4, l7);
                g11.fillRect(168, 8 + ac9.dA * (l7 / ac9.dB), 4, l7 / ac9.dB);
                g4.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            } else {
                ac2.u.a(g4, s1, 88, k4, 3);
            }
            ac2.a(g4);
        }
        if ((i1 & 0x10) != 0) {
            c(g1);
            cn.a(ci);
            if (gameState == 10 && R == 0 && cn.s != 0) {
                int j1 = c(cn.o.a - ci.a);
                int k1 = c(cn.o.b - ci.b);
                int i2;
                if ((i2 = cn.E << 1) < 9)
                    i2 = 9;
                else if (i2 > 77)
                    i2 = 77;
                a(g1, cZ, i2, j1, k1);
            }
        }
        if ((i1 & 0x40) != 0)
            j.a_(g1);
        if ((i1 & 0x20000) != 0)
            K.c(g1);
        if ((i1 & 4) != 0) {
            Graphics g5 = g1;
            MainThread ac3 = this;
            if (gameState == 7) {
                if (ac3.G > 0) {
                    if (ac3.bR - ac3.F > 100L) {
                        ac3.G = Math.max(ac3.G - 14, 0);
                        ac3.F = ac3.bR;
                    }
                    if (ac3.G < 64)
                        ac3.ck.k = 0;
                    else
                        ac3.ck.k = 5;
                }
                if (ac3.ck.w) {
                    g5.setColor(0xff0000);
                    g5.fillRect(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
                    if (ac3.ck.M[2] < ac3.bR)
                        ac3.L.a(8);
                    ac3.ck.w = false;
                }
            }
            if (ac3.dv != -1) {
                Image image = ac3.imageResources[ac3.dv];
                Graphics g9 = g5;
                MainThread ac7 = ac3;
                int j7 = image.getWidth();
                int i8 = image.getHeight();
                int j6 = c(ac7.ci.a * 3 >> 1);
                int l5;
//                int l6;
                if ((l5 = -(c(ac7.ci.b * 3 >> 1)) % i8) > 0)
                    l5 -= i8;
                do {
                    int l4;
                    if ((l4 = -j6 % j7) > 0)
                        l4 -= j7;
                    do
                        g9.drawImage(image, l4, l5, 20);
                    while ((l4 += j7) < DeviceInfo.DEVICE_SCREEN_WIDTH);
                } while ((l5 += i8) < DeviceInfo.DEVICE_SCREEN_HEIGHT);
            }
            int i6 = c(ac3.ci.a * 3 >> 1);
            int k6 = c(ac3.ci.b * 3 >> 1);
            int i7 = ac3.cz * 3 >> 1;
            int k7 = ac3.cy * 3 >> 1;
            while (i6 < 0) {
                i6 += i7;
            }
            while (k6 < 0) {
                k6 += k7;
            }
            i6 %= i7;
            k6 %= k7;
            for (int j8 = 0; j8 < ac3.ds.length; j8++) {
                int ai1[];
                int i4 = h((((ai1 = ac3.ds[j8])[1] * 3 >> 1) - i6) + 88, i7);
                int i5 = h(((ai1[2] * 3 >> 1) - k6) + 104, k7);
                if (i4 > -ai1[3] && i4 < DeviceInfo.DEVICE_SCREEN_WIDTH && i5 > -ai1[4] && i5 < DeviceInfo.DEVICE_SCREEN_HEIGHT)
                    g5.drawImage(ac3.imageResources[ai1[0]], i4, i5, 20);
            }

        } else if ((i1 & 0x40000) != 0)
            j.b_(g1);
        if ((i1 & 0x10000) != 0) {
            Graphics g6 = g1;
            MainThread ac4 = this;
            for (int j2 = 0; j2 < ac4.n.size(); j2++) {
                Object aobj[];
                int j4 = ((Integer) (aobj = (Object[]) ac4.n.elementAt(j2))[0]).intValue();
                String s3 = (String) aobj[1];
                cls_aa aa1 = (cls_aa) aobj[2];
                cls_b b1 = (cls_b) aobj[3];
                if (aa1.e == 1) {
                    ac4.n.removeElementAt(j2--);
                    continue;
                }
                byte byte0;
                if (j4 == 0) {
                    if (j2 == ac4.n.size() - 1) {
                        String s4 = "";
                        if (Integer.parseInt(s3) >= 15)
                            s4 = "!!";
                        s3 = s3 + ac4.strs[155] + s4;
                    }
                    s3 = "+" + s3;
                    byte0 = 36;
                } else {
                    byte0 = 3;
                }
                b1.a(g6, s3, c(aa1.a - ac4.ci.a), c(aa1.b - ac4.ci.b), byte0);
                aa1.c();
            }

        }
        if ((i1 & 0x4000) != 0)
            c(g1);
        if ((i1 & 0x100) != 0)
            K.d(g1);
        if ((i1 & 0x400) != 0)
            y.a.a(g1);
        else if ((i1 & 8) != 0)
            K.a(g1);
        else if ((i1 & 0x200) != 0) {
            Graphics g7 = g1;
            MainThread ac5 = this;
            int k2 = c(cj.a);
            int j3 = c(ac5.cj.b);
            String s2 = cls_b.a(ac5.cB);
            int j5 = ac5.w.e(s2);
            g7.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            g7.setColor(0);
            g7.fillRect(0, 104 - ((j5 >> 1) + 6), DeviceInfo.DEVICE_SCREEN_WIDTH, j5 + 6 + 3);
            ac5.w.a(g7, s2, k2 + 88, j3, 3);
        } else if ((i1 & 0x20) != 0)
            d(g1);
        if ((i1 & 0x800) != 0) {
            Graphics g8 = g1;
            MainThread ac6 = this;
            if (di < ac6.dj + ac6.dk) {
                g8.setColor(0);
                g8.fillRect(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
                g8.setColor(0xf9f9f9);
                g8.drawRect(6, 96, 164, 16);
                g8.setClip(0, 0, 169, DeviceInfo.DEVICE_SCREEN_HEIGHT);
                g8.setColor(0xff2222);
                g8.fillRect(8, 98, ac6.dl, 13);
                if (ac6.strs[117] != null && ac6.recordManager.language != null)
                    ac6.p.a(g8, ac6.strs[117], 88, 93, 33);
            }
        }
        if ((i1 & 0x80) != 0)
            e(g1);
        if ((i1 & 0x1000) != 0) {
            g1.drawImage(img25, 0, 0, 20);
            p.a(g1, strs[234], 88, 4, 1);
            K.b(g1);
        }
        if ((i1 & 0x80000) != 0)
            p.a(g1, strs[257], 88, 104, 33);
        if (dz == 6 && cI && R == 0) {
            g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            u.a(g1, "CHEATER!", 0, DeviceInfo.DEVICE_SCREEN_HEIGHT, 36);
        }
        if (gameState == 7 || A)
            P++;
        cU = 0;
    }

    private void c(Graphics g1) {
        MainThread ac1;
        int l3;
        int j3 = (ac1 = this).ci.a + ((88) << 8);
        l3 = ac1.ci.b;
        if (ac1.gameState != 10)
            l3 += (l3 = 104) << 8;
        else
            l3 += (l3 = 78) << 8;
        if (ac1.cn.o.a != j3)
            ac1.ci.a += (ac1.cn.o.a - j3) / 3;
        if (ac1.cn.o.b != l3)
            ac1.ci.b += (ac1.cn.o.b - l3) / 6;
        if (ac1.R == 1) {
            ac1.ci.a = 0;
            ac1.ci.b = Math.max(ac1.ci.b, 0);
//            char c1;
            ac1.ci.b = Math.min(ac1.ci.b, 47616 - (('\320') << 8));
        }
        if (bY > bR) {
            if ((P & 1) == 0) {
                g1.setColor(0xffff88);
                for (int i1 = 0; i1 < o.size() - 1; i1++) {
                    cls_aa aa1 = (cls_aa) o.elementAt(i1);
                    cls_aa aa2 = (cls_aa) o.elementAt(i1 + 1);
//                    int i4;
                    int l2 = (aa1.a - ci.a) >> 8;
                    int k3 = (aa1.b - ci.b) >> 8;
                    int l1 = (aa2.a - ci.a) >> 8;
                    int j2 = (aa2.b - ci.b) >> 8;
                    a(g1, l2, k3, l1, j2);
                }

            }
        } else if (o.size() > 0)
            o.removeAllElements();
//        int j1;
        for (int k2 = fld_m_Vector.size() - 1; k2 >= 0; k2--) {
            cls_d d1;
            if ((d1 = (cls_d) fld_m_Vector.elementAt(k2)).x || d1.equals(cn))
                continue;
            if (R == 0 && gameState == 7 && (d1.v || d1.equals(cm))) {
//                int j4;
                int k1 = (d1.o.a - ci.a) >> 8;
                int i2 = (d1.o.b - ci.b) >> 8;
                if ((ck.H & 0x400) != 0 && d1.B < ck.B) {
                    int l4 = i2;
                    int k4 = k1;
                    cls_d d2 = d1;
                    Graphics g2 = g1;
                    MainThread ac2 = this;
                    int i5 = d2.B >> 2;
                    byte byte0;
                    byte byte1;
                    if (ac2.P % 3 == 0)
                        byte0 = byte1 = 2;
                    else
                        byte0 = byte1 = 0;
                    int j5 = ac2.K.img1.getHeight();
                    int k5 = ac2.K.img97.getHeight() + 2;
                    if (k4 + i5 < 0 && l4 + i5 < j5)
                        ac2.cY.a(g2, byte0, j5 + byte1, 6, 0, 20);
                    else if (k4 - i5 > DeviceInfo.DEVICE_SCREEN_WIDTH && l4 + i5 < k5)
                        ac2.cY.a(g2, DeviceInfo.DEVICE_SCREEN_WIDTH - ac2.cY.f - byte0, k5 + byte1, 10, 0, 20);
                    else if (k4 + i5 < 0 && l4 - i5 > DeviceInfo.DEVICE_SCREEN_HEIGHT)
                        ac2.cY.a(g2, byte0, DeviceInfo.DEVICE_SCREEN_HEIGHT - ac2.cY.g - byte1, 2, 0, 20);
                    else if (k4 - i5 > DeviceInfo.DEVICE_SCREEN_WIDTH && l4 - i5 > DeviceInfo.DEVICE_SCREEN_HEIGHT)
                        ac2.cY.a(g2, DeviceInfo.DEVICE_SCREEN_WIDTH - ac2.cY.f - byte0, DeviceInfo.DEVICE_SCREEN_HEIGHT - ac2.cY.g - byte1, 14, 0, 20);
                    else if (k4 - i5 > DeviceInfo.DEVICE_SCREEN_WIDTH)
                        ac2.cY.a(g2, DeviceInfo.DEVICE_SCREEN_WIDTH - ac2.cY.f - byte0, l4, 12, 0, 20);
                    else if (k4 + i5 < 0)
                        ac2.cY.a(g2, byte0, l4, 4, 0, 20);
                    else if (l4 - i5 > DeviceInfo.DEVICE_SCREEN_HEIGHT)
                        ac2.cY.a(g2, k4, DeviceInfo.DEVICE_SCREEN_HEIGHT - ac2.cY.g - byte1, 0, 0, 20);
                    else if (l4 + i5 < 0 && k4 < ac2.K.N)
                        ac2.cY.a(g2, k4, j5 + byte1, 8, 0, 20);
                    else if (l4 + i5 < 0 && k4 < ac2.K.O)
                        ac2.cY.a(g2, k4, j5 + byte1, 8, 0, 20);
                    else if (l4 + i5 < 0)
                        ac2.cY.a(g2, k4, k5 + byte1, 8, 0, 20);
                }
                if (d1.equals(cl) && cl.B < ck.B && !B) {
                    int i3;
                    if ((i3 = d1.E << 1) < 9)
                        i3 = 9;
                    cls_u u1;
                    if (d1 != ck.c)
                        u1 = bL;
                    else
                        u1 = cZ;
                    a(g1, u1, i3, k1, i2);
                }
            }
            if (d1.v)
                d1.a(ci);
        }

        if (bN != null) {
            bN.a(bR);
            bO.a(bR);
        }
        if (bF != null)
            bF.a(bR);
        if (bG != null)
            bG.a();
    }

    private void d(Graphics g1) {
        g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
        g1.setColor(0);
        if (gameState == 4 && sporeEALogo != null) {
            g1.drawImage(sporeEALogo, 88, 104, 3);
            return;
        }
        if (gameState == 5 && consumerLogo != null) {
            g1.drawImage(consumerLogo, 88, 4, 17);
            a(g1);
            return;
        }
        if (gameState == 2 && consumerLogo != null) {
            g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            g1.setColor(0xffffff);
            g1.fillRect(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            g1.drawImage(consumerLogo, DeviceInfo.DEVICE_SCREEN_WIDTH - consumerLogo.getWidth() >> 1, DeviceInfo.DEVICE_SCREEN_HEIGHT - consumerLogo.getHeight() >> 1, 0);
            return;
        }
        if (gameState == 3 && consumerLogo != null) {
            g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            g1.setColor(0xffffff);
            g1.fillRect(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            g1.drawImage(consumerLogo, DeviceInfo.DEVICE_SCREEN_WIDTH - consumerLogo.getWidth() >> 1, DeviceInfo.DEVICE_SCREEN_HEIGHT - consumerLogo.getHeight() >> 1, 0);
        }
    }

    private void e(Graphics g1) {
        g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
        int i1;
        if (cu) {
            if ((_flddo.d) >> 8 != 0)
                _flddo.b(0, 0, 3);
        } else if ((_flddo.d) >> 8 != -img25.getHeight())
            _flddo.b(0, -img25.getHeight(), 3);
        if (dq) {
            if ((dp.d) >> 8 != DeviceInfo.DEVICE_SCREEN_HEIGHT)
                dp.b(0, DeviceInfo.DEVICE_SCREEN_HEIGHT, 3);
        } else if ((dp.d) >> 8 != DeviceInfo.DEVICE_SCREEN_HEIGHT + img24.getHeight())
            dp.b(0, DeviceInfo.DEVICE_SCREEN_HEIGHT + img24.getHeight(), 3);
        cs.a(bP);
        _flddo.b();
        dp.b();
        if (y.a.s != 0)
            cu = true;
        else
            cu = false;
        i1 = (_flddo.b) >> 8;
        if ((gameState != 6 || y.a.fld_b_int != 6) && i1 > -img25.getHeight() && gameState != 9 && gameState != 8) {
            g1.drawImage(img25, 0, i1, 20);
            if (aU)
                p.a(g1, strs[257], 88, i1 + 4, 1);
            else
                p.a(g1, strs[y.a.s], 88, i1 + 4, 1);
        }
        if (da != 6 || db != 6) {
            dq = true;
//            int j1;
            if (gameState != 7 && gameState != 9 && gameState != 12 && gameState != 13)
                g1.drawImage(img24, 0, (dp.b) >> 8, 36);
            if (aU) {
                bJ.a(g1, 172, ((dp.b) >> 8) - 2, 2, 0, 40);
                return;
            }
            if (da > 6) {
                Object obj = K;
//                int iobj;
                if (ck.Q < bR) {
                    ((cls_j) (obj)).fld_b_u.a(g1, 4, ((dp.b) >> 8) - 2, (da - 6) * 3 - 1, 0, 36);
                } else {
                    ((cls_j) (obj)).a.a(g1, 4, ((dp.b) >> 8) - 2, (da - 6) * 3 - 1, 0, 36);
                }
            } else if (da != 6)
                bJ.a(g1, 4, ((dp.b) >> 8) - 2, da, 0, 36);
            if (db != 6) {
                bJ.a(g1, 172, (dp.b >> 8) - 2, db, 0, 40);
            }
        } else {
            dq = false;
        }
    }

    public final void paint(Graphics g1) {
        if (p == null)
            return;
        cM = true;
        if (bufferImage != null) {   // if bufferImage valid, then draw image
            g1.setClip(0, 0, DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
            g1.drawImage(bufferImage, 0, 0, 20);
        } else {
            bufferGraphics = g1;
            a(bufferGraphics, 0);
            cU = 0;
        }
        cM = false;
    }

    private void p() {
        switch (cP) {
            case 0:
                recordManager = new RecordManager(this);
                recordManager.resetPrefs();
                recordManager.loadPrefs();
                System.out.println("Language = " + recordManager.language);
                if (!isSupportLanguage(recordManager.language))
                    recordManager.language = null;
                language = sporeInstance.getAppProperty("language");
                if (language == null && recordManager.language == null) {
                    forceLocale = sporeInstance.getAppProperty("Force-Locale");
                    String s1 = forceLocale;
                    if (forceLocale != null && forceLocale.startsWith("auto-")) {
                        forceLocale = System.getProperty("microedition.locale");
                        if (forceLocale != null)
                            forceLocale = forceLocale.substring(0, 2);
                        if (!isSupportLanguage(forceLocale)) {
                            forceLocale = s1;
                            forceLocale = forceLocale.substring(5);
                        }
                    }
                    if (!isSupportLanguage(forceLocale))
                        forceLocale = null;
                    if (forceLocale == null) {
                        forceLocale = System.getProperty("microedition.locale");
                        if (forceLocale != null)
                            forceLocale = forceLocale.substring(0, 2);
                    } else if (forceLocale.equals("menu"))
                        forceLocale = null;
                    if (!isSupportLanguage(forceLocale))
                        forceLocale = null;
                    if (forceLocale != null)
                        forceLocale = forceLocale.substring(0, 2);
                }
                return;

            case 1:
                try {
                    InputStream inputStream = sporeInstance.getClass().getResourceAsStream("/19.bin");
                    DataInputStream din = new DataInputStream(inputStream);
                    cC = new int[51][];
                    for (int k2 = 0; k2 < 51; k2++) {
                        cC[k2] = new int[7];
                        cC[k2][0] = din.readInt();
                        cC[k2][1] = din.readUnsignedByte();
                        cC[k2][2] = din.readUnsignedByte();
                        cC[k2][3] = din.readUnsignedShort();
                        cC[k2][4] = din.readUnsignedShort();
                        if ((k2 & 1) == 0)
                            a();
                    }

                    return;
                }
                catch (IOException _ex) {
                    return;
                }

            case 2:
                recordManager.a = false;
                a();
                return;

            case 3:
                img25 = loadUnencodeImage(25);
                img24 = loadUnencodeImage(24);
                bJ = new cls_u(106, 85);
                a();
                _flddo = new cls_aa(0, -img25.getHeight());
                dp = new cls_aa(0, DeviceInfo.DEVICE_SCREEN_HEIGHT + img24.getHeight());
                a();
                y = new cls_ae(this);
                K = new cls_w(this);
                a();
                q();
                return;

            case 4:
                b();
                return;

            case 5:
                a();
                System.out.println("loading tempLang " + null);
                a();
                v();
                return;

            case 6:
                cE = new int[10][];
                for (int i1 = 0; i1 < 10; i1++)
                    cE[i1] = r(i1 + 5);

                ck = new cls_d(this, 0, 0, 0);
                a();
                cls_d d1 = new cls_d(this, 0, 0, 0);
                cA = b(d1);
                if (recordManager.i == null || recordManager.i.equals(""))
                    recordManager.i = cA;
                if (recordManager.h == null || recordManager.h.equals(""))
                    recordManager.h = cA;
                a();
                return;

            case 7:
                bb = new cls_a(2, 93, r(25));
                cZ = new cls_u(bb);
                a();
                return;

            case 8:
                try {
                    InputStream inputstream = sporeInstance.getClass().getResourceAsStream("/20.bin");
                    DataInputStream datainputstream = new DataInputStream(inputstream);
                    cD = new byte[38][];
                    for (int i3 = 0; i3 < 38; i3++) {
                        cD[i3] = new byte[19];
                        for (int j1 = 0; j1 < 19; j1++)
                            cD[i3][j1] = datainputstream.readByte();

                        if ((i3 & 1) == 0)
                            a();
                    }

                    return;
                }
                catch (IOException _ex) {
                    return;
                }

            case 9:
                bL = cY;
                a();
                bd = new cls_a(113, 80);
                bI = new cls_u(bd);
                a();
                bF = new cls_u(166, 68);
                bF.l = 150;
                bG = new cls_u(152, 55);
                img12 = loadUnencodeImage(12);  // TODO Is what?
                a();
                for (int k1 = 0; k1 < 7; k1++)
                    cG[k1] = new cls_u(k1 + 158, k1 + 58);

                a();
                return;

            case 10:
                co = new Vector();
                cp = new Vector();
                a();
                if (!recordManager.e()) {
                    recordManager.f();
                    q(2);
                }
                recordManager.h();
                a();
                return;

            case 11: // '\013'
                String s2 = sporeInstance.getAppProperty("ENABLE_TAF");
                if ((s2) != null)
                    enableTAF = s2.equals("true");
                sporeInstance.getAppProperty("NetworkFees-Text");
                s2 = sporeInstance.getAppProperty("MG_Impl");
                if ((s2) == null) {
                    mgImpl_static = false;
                    mgImpl_wap = false;
                } else if (s2.equals("static")) {
                    mgImpl_wap = false;
                    mgImpl_static = true;
                } else if (s2.equals("wap")) {
                    mgImpl_wap = true;
                    mgImpl_static = false;
                } else if (s2.equals("wapstatic")) {
                    mgImpl_wap = true;
                    mgImpl_static = true;
                } else {
                    mgImpl_wap = false;
                    mgImpl_static = false;
                }
                a();
                s2 = sporeInstance.getAppProperty("MG_PRODUCTS");
                cw = 0;
                char ac1[] = null;
                if (s2 != null) {
                    ac1 = s2.toCharArray();
                    for (int l1 = 0; l1 < ac1.length; l1++) {
                        if (ac1[l1] == ',' || l1 + 1 == ac1.length) {
                            cw++;
                        }
                    }
                }
                if (cw != 0 && ac1 != null) {
                    int i2 = 0;
//                    boolean flag = false;
                    int j3 = 0;
                    cv = new String[cw][];
                    for (int k3 = 0; k3 < ac1.length; k3++) {
                        if (ac1[k3] == ',' || k3 + 1 == ac1.length) {
                            int l2 = ac1[k3] != ',' ? k3 + 1 : k3;
                            cv[j3] = new String[3];
                            cv[j3][0] = sporeInstance.getAppProperty("MG_BUYURI_".concat(String.valueOf(ac1).substring(i2, l2)));
                            cv[j3][1] = sporeInstance.getAppProperty("MG_CATURI_".concat(String.valueOf(ac1).substring(i2, l2)));
                            cv[j3][2] = String.valueOf(ac1).substring(i2, l2);
                            if (cv[j3][0] != null && cv[j3][0].trim().length() == 0)
                                cv[j3][0] = null;
                            if (cv[j3][1] != null && cv[j3][1].trim().length() == 0)
                                cv[j3][1] = null;
                            j3++;
                            i2 = k3 + 1;
                        }
                    }

                    j3 = 0;
                    int l3;
                    for (int j2 = 0; j2 < cv.length; j2 = l3) {
                        l3 = j2;
                        boolean flag1;
                        do {
                            if (flag1 = !cv[l3][2].equals("TET") && !cv[l3][2].equals("SIM") && !cv[l3][2].equals("HAP"))
                                j3++;
                            l3++;
                        } while (flag1 && l3 < cv.length);
                        if (j2 + j3 >= cv.length)
                            continue;
//                        for (j2 = j2; j2 < cw - j3; j2++)
                        for (; j2 < cw - j3; j2++)
                            cv[j2] = cv[j2 + j3];

                    }

                    cw -= j3;
                }
                a();
                cd = new char[11][];
                cd[0] = (new char[]{
                        '0'
                });
                cd[1] = (new char[]{
                        '1', '.', ',', '?', '!', '-', '\'', '`', '"', ':',
                        ';', '+', '_', '=', '@', '#', '$', '%', '^', '&',
                        '*', '(', ')', '{', '}', '[', ']', '<', '>', '/',
                        '\\'
                });
                cd[2] = (new char[]{
                        '2', 'A', 'B', 'C', 'a', 'b', 'c'
                });
                cd[3] = (new char[]{
                        '3', 'D', 'E', 'F', 'd', 'e', 'f'
                });
                cd[4] = (new char[]{
                        '4', 'G', 'H', 'I', 'g', 'h', 'i'
                });
                cd[5] = (new char[]{
                        '5', 'J', 'K', 'L', 'j', 'k', 'l'
                });
                cd[6] = (new char[]{
                        '6', 'M', 'N', 'O', 'm', 'n', 'o'
                });
                cd[7] = (new char[]{
                        '7', 'P', 'Q', 'R', 'S', 'p', 'q', 'r', 's'
                });
                cd[8] = (new char[]{
                        '8', 'T', 'U', 'V', 't', 'u', 'v'
                });
                cd[9] = (new char[]{
                        '9', 'W', 'X', 'Y', 'Z', 'w', 'x', 'y', 'z'
                });
                cd[10] = (new char[]{
                        ' '
                });
                a();
                y.a();
                return;

            case 12: // '\f'
                L.c();
                L.mainThread = this;
                return;

            case 13:
                K.a();
                x();
                b();
                break;
        }
    }

    private void q() {
        cX = new cls_a(2, 93);
        cY = new cls_u(cX);
        a();
        cls_a a1 = new cls_a(2, 93, r(26));
        bK = new cls_u(a1);
        a();
    }

    final void d() {
        int i1 = 55;
        int k1 = 0x7fffffff;
        cl = null;
        cm = null;
        if (R == 1) {
            if (bW < bR && ck.D != 0) {
                L.b(11);
                ck.B = ck.D;
                ck.D = 0;
                ck.a();
                ck.M[11] = 1500L + bR;
                ck.I = 1;
            }
            if (bV > bR)
                cc = ++cc % 4;
            if (B && bS < bR) {
                gameState = 12;
                return;
            }
        } else if (R == 0 && gameState == 7) {
            if ((ck.H & 0x400) != 0)
                i1 += 30;
            else if ((ck.H & 0x200) != 0)
                i1 += 20;
            else if ((ck.H & 0x100) != 0)
                i1 += 10;
            i1 *= i1;
            if (bT > bR) {
                ck.u = false;
                if (ck.c != null && !ck.c.x) {
                    int i2 = a(ck.o, ck.c.o);
                    int l2;
                    if (Math.abs(l2 = ck.l - (i2 != 0 ? i2 : 256)) <= ck.A)
                        ck.l = i2;
                    else if ((0xff & l2) < 128)
                        ck.l -= ck.A;
                    else
                        ck.l += ck.A;
                }
                ck.l &= 0xff;
                ck.fld_m_int = ck.l;
                if (ak > 0 && I) {
                    bT = 0L;
                    ck.c = null;
                    ck.d = Math.min(ck.d, ck.e);
                }
            } else {
                bT = 0L;
                ck.c = null;
            }
            if (ai >= inf_m.ab[T]) {
                ck.d = ck.e;
                if (!B) {
                    B = true;
                    cn = new cls_d(this, 50, 0, 0);
                    cn.o = ck.o.a();
                }
                a(ck);
                if (!ck.v) {
                    gameState = 12;
                    return;
                }
            }
            if (bv[ck.f] != null || bw[ck.f] != null) {
                int j2 = (ck.d * 100) / ck.e;
                j2 = Math.min(100, j2);
                int i3 = 900 - j2 * 9;
                if (bv[ck.f] != null && bv[ck.f].l != i3)
                    bv[ck.f].l += c(b(i3 - bv[ck.f].l) / 100);
                if (bw[ck.f] != null && bw[ck.f].l != i3) {
                    bw[ck.f].l += c(b(i3 - bw[ck.f].l) / 100);
                    bx[ck.f].l = bw[ck.f].l;
                }
            }
            if (bn[ck.f] != null && (ck.H & 4) != 0 && ck.Q < bR && bn[ck.f].j == 0) {
                bn[ck.f].j = 3;
                bn[ck.f].m = bR;
            }
            if (ck.M[3] < bR && ck.M[3] != 0L) {
                L.b(17);
                ck.M[3] = 0L;
            }
            if (ck.M[2] < bR && ck.M[2] != 0L) {
                try {
                    Thread.sleep(60L);
                }
                catch (Exception _ex) {
                }
                L.b(15);
                ck.M[2] = 0L;
            }
            if (ck.M[0] < bR && ck.M[0] != 0L) {
                L.b(18);
                ck.M[0] = 0L;
            }
        }
        int k2 = c((ci.a << 1) >> 1) % cz;
        int j3 = c((ci.b << 1) >> 1) % cy;
        if (k2 < 0)
            k2 += cz;
        if (j3 < 0)
            j3 += cy;
        k2 -= 88;
        j3 -= 104;
        int k3 = fld_m_Vector.size();
        for (int l3 = 0; l3 < k3; l3++) {
            cls_d d2;
            if ((d2 = (cls_d) fld_m_Vector.elementAt(l3)).c != null && d2.c.x)
                d2.c = null;
            if (d2.x) {
                if (d2.s != 18) {
                    if (R == 0)
                        if (d2.s == 13)
                            ai = inf_m.ab[T];
                        else if (d2.s == 14) {
                            ai += inf_m.ab[T] / 18;
                            cls_d d3;
                            (d3 = d2.b).a = null;
                            d3.O--;
                            if (d2.F <= 0)
                                d3.F = d3.G;
                            d3.N = true;
                            d3.Q = bR + 3000L;
                            d3.c = ck;
                            d3.t = 0;
                            d3.e += 2;
                            d3.A++;
                            d2.a(4, -1);
                        }
                    fld_m_Vector.removeElementAt(l3--);
                    k3--;
                    if (d2.equals(cn))
                        k();
                    if ((d2.H & 0x1000) == 0)
                        continue;
                    cls_d d4 = new cls_d(this, d2.r, j(cz), j(cy));
                    (d4).l = d4.fld_m_int = j(256);
                    d4.d = d4.e;
                    fld_m_Vector.addElement(d4);
                    a(d4);
                    if (d4.v) {
                        int l4 = a(cn.o, d4.o);
                        d4.o.a += (cz >> 1) * g(l4);
                        d4.o.b += (cy >> 1) * f(l4);
                        a(d4);
                    }
                    if (d4.q == null)
                        continue;
                    for (int i5 = 0; i5 < d4.q.length; i5++) {
                        d4.q[i5].a = d4.o.a;
                        d4.q[i5].b = d4.o.b;
                    }

                    continue;
                }
                if ((d2.H & 0x1000) != 0) {
                    d2.x = false;
                    d2.l = d2.fld_m_int = j(256);
                    d2.o.a = j(cz);
                    d2.o.b = j(cy);
                    a(d2);
                    continue;
                }
                fld_m_Vector.removeElementAt(l3--);
                k3--;
                if (d2.equals(cn))
                    k();
                gameState = 12;
                B = true;
                continue;
            }
            d2.y = false;
            if (R != 0 || d2.s == 0)
                continue;
            if ((d2.H & 0x2000) == 0) {
                int k4 = c(d2.o.a - ck.o.a);
                int j5 = c(d2.o.b - ck.o.b);
                j5 = k4 * k4 + j5 * j5;
                if (G < 64 && d2.B < ck.B) {
                    if (j5 < i1) {
                        i1 = j5;
                        cl = d2;
                    }
                    if (j5 < k1) {
                        k1 = j5;
                        cm = d2;
                    }
                }
            }
            if (B && d2.s == 12 && d2.b != null)
                d2.N = true;
        }

        int i4 = fld_m_Vector.size();
        for (int j4 = 0; j4 < i4; j4++) {
            cls_d d5 = (cls_d) fld_m_Vector.elementAt(j4);
            int iobj = 0;
            if (R == 1)
                switch (d5.s) {
                    case 0:
                        break;

                    case 23: // '\027'
                    case 24: // '\030'
                        if (bX > bR && (d5.r == 42 || cr == -1)) {
                            if (d5.o.c != ck.o.a || d5.o.d != ck.o.b)
                                if (d5.o.g == 0L)
                                    d5.o.a(c(ck.o.a), c(ck.o.b), 910L, bR);
                                else
                                    d5.o.a(ck.o, bR);
                            d5.o.a(bR);
                        }
                        break;

                    default:
                        if (d5.j != 1 && !B || --d5.B != 0)
                            break;
                        d5.x = true;
                        if (d5.j == 1) {
                            cF += 1000L;
                            recordManager.a(3, 1, d5.r);
                            cls_aa aobj = d5.o.a();
                            int j1 = 15 * g(192);
                            int l1 = 15 * f(192);
                            aobj.a(c(d5.o.a + j1), c(d5.o.b + l1), 25);
                            a(2, Integer.toString(inf_m.ad[d5.r - 38]), aobj, u);
                        }
                        continue;
                }
            if (bU > bR && d5.s != 0 && d5.s != 23 && d5.s != 12 && P % 4 != 0)
                iobj = 1;
            if (iobj == 0) {
                if (!d5.equals(ck) && (d5.M[0] > bR || d5.M[5] > bR) && (P & 1) == 0) {
                    d5.d = 2;
                    if (d5.M[3] < bR) {
                        d5.l = 0xff & d5.l + (j(64) - 32);
                        d5.fld_m_int = 0xff & d5.fld_m_int + (j(64) - 32);
                    }
                }
                d5.e(1);
            }
            if (R == 0 && (d5.H & 0x2000) == 0)
                c(d5, k2, j3);
            for (int k5 = j4 + 1; k5 < i4; k5++) {
                cls_d d1 = (cls_d) fld_m_Vector.elementAt(k5);
                if ((R != 0 || d1.v) && !d1.x)
                    b(d5, d1, i4);
            }

            if (cn.v || d5.equals(cn))
                a(d5);
        }

    }

    private void b(cls_d d1, cls_d d2, int i1) {
        label0:
        {
            cls_d d4;
            int k1;
            int i2;
            int k2;
            cls_d d5;
            boolean flag;
            boolean flag1;
            label1:
            {
                int j1 = d2.E + d1.E;
                k1 = c(d1.o.a - d2.o.a);
                i2 = c(d1.o.b - d2.o.b);
                k2 = k1 * k1 + i2 * i2;
                if (k1 * k1 < 0 || i2 * i2 < 0 || k2 < 0) {
                    d1.d = 2;
                    d2.d = 2;
                    return;
                }
                int i3;
                int j3;
                if ((j3 = (i3 = c(e(k2))) - j1) < 200 || d1.c == d2 || d2.c == d1) {
                    d1.a(d2, j3);
                    d2.a(d1, j3);
                }
                if (i3 >= j1)
                    break label0;
                d1.a(d2);
                d2.a(d1);
                if (R == 1)
                    break label0;
                if (B && a(d1, d2, 0) && !a(d1, d2, 16) && !a(d1, d2, 1)) {
                    cls_d d3 = d1.equals(ck) ? d2 : d1;
                    d3.f(10000);
                    return;
                }
                if (a(d1, d2, 7)) {
                    if (!a(d1, d2, 12)) {
                        a(d1, d2, k2, k1, i2);
                        return;
                    }
                    break label0;
                }
                d4 = null;
                d5 = null;
                flag = false;
                flag1 = false;
                if (d1.s != d2.s) {
                    if (d1.B > d2.B) {
                        d4 = d1;
                        d5 = d2;
                        break label1;
                    }
                    if (d1.B < d2.B) {
                        d4 = d2;
                        d5 = d1;
                        break label1;
                    }
                    if (d1.equals(ck) && d2 == ck.c) {
                        d4 = ck;
                        d5 = d2;
                        break label1;
                    }
                    if (d1.equals(ck) || d2.equals(ck)) {
                        d4 = d1.equals(ck) ? d2 : d1;
                        d5 = d1.equals(ck) ? d1 : d2;
                        flag1 = true;
                    }
                }
                flag = true;
            }
            if (flag)
                a(d1, d2, k2, k1, i2);
            if (d4 != null && d5 != null)
                if (d4.s == 17 && d5.s == 1 || d4.s == 13 && d5.s == 14 || d4.s == 13 && d5.s == 1 || d5.s == 9 || d5.s == 12 || d4.s == d5.s)
                    d4 = null;
                else if (d5.s == 13 && d5.O > 0) {
                    if (d4.s == 0) {
                        d2 = d4;
                        d4 = d5;
                        d5 = d2;
                    } else {
                        d5 = null;
                    }
                } else if (d5.s == 15 && (d5.H & 0x10) != 0) {
                    if (d4.equals(ck)) {
                        bT = 0L;
                        H = false;
                    }
                    a(d4, d5, k2, k1, i2);
                    d5 = null;
                } else if (d4.s == 11 && d4.j == 2) {
                    d5.f(d4.z);
                    a(d4, d5, k2, k1, i2);
                    d4.j = 0;
                    d4.d = 2;
                } else if (d4.s == 10 && d5.s == 11 && d5.j == 2) {
                    d4.f(d4.z);
                    a(d4, d5, k2, k1, i2);
                    d4.M[5] = bR + 2500L;
                } else if (a(d4, d5, 16)) {
                    d4.a(d5);
                    d5.a(d4);
                    d4 = null;
                    d5 = null;
                }
            if (d4 != null && d5 != null) {
                if (d5.s == 0) {
                    int id2 = 1;
                    int k3 = a(ck.o, d4.o);
                    int l4;
                    if ((l4 = 0xff & ck.fld_m_int - k3) < 64 || l4 > 192) {
                        int l5 = 0;
                        if (ck.M[6] > bR) {
                            l5 += 4;
                            d4.b(5, 2500);
                            L.a(6);
                        }
                        if (ck.M[7] > bR) {
                            l5 += 10;
                            if (ck.M[6] <= bR)
                                L.a(6);
                        }
                        if (l5 > 0) {
                            if (d4.s == 10)
                                l5 = 1;
                            d4.f(l5);
                            ck.C <<= 1;
                            a(d4, ck, k2, k1, i2);
                            ck.C >>= 1;
                            d4.fld_m_int = d4.l;
                            ck.fld_m_int = ck.l;
                            id2 = 0;
                        }
                    }
                    if (id2 != 0 && !flag1) {
                        if (d4.s != 6 || d4.P != 0)
                            ck.f(Math.max(1, Math.min(12, d4.B / 9)));
                        if (d4.s == 11 && ck.M[3] > bR) {
                            d4.f(cC[34][2]);
                            d4.j = 0;
                            d4.b(5, 2500);
                        }
                        if ((ck.H & 0x10) != 0) {
                            ck.M[9] = bR + 3000L;
                            d4.f(4);
                            ck.C <<= 4;
                            ck.p.a = a(2560, g(ck.l));
                            ck.p.b = a(2560, f(ck.l));
                            a(d4, ck, k2, k1, i2);
                            ck.C >>= 4;
                            d4.fld_m_int = d4.l;
                            ck.fld_m_int = ck.l;
                        }
                    }
                    if (ck == d4.c && d4.r != 27)
                        d4.d = 2;
                    return;
                }
                if (d5.s == 18) {
                    d5.f(Math.max(1, Math.min(12, d4.B / 9)));
                    return;
                }
                if (!flag1) {
                    if (d4.s == 0) {
                        if (d4.c == d5)
                            d4.c = null;
                        recordManager.a(0, 1, d5.B);
                        if (!recordManager.s && T < 3 && bT < bR)
                            bZ = bR + 2000L;
                        else if (bT > bR) {
                            recordManager.s = true;
                            bZ = 0L;
                        }
                        if (T != 14)
                            ai++;
                        if (bS > bR && ak > 0) {
                            if (++ak > al) {
                                al = ak;
                                recordManager.a(2, ak, ak);
                            }
                            cls_aa ad2 = ck.o.a();
                            int l3 = 40 * (g(128 + ck.l) + 128);
                            int i5 = 40 * (f(128 + ck.l) + 128);
                            ad2.a(c(ck.o.a + l3), c(ck.o.b + i5), 25);
                            cls_b b1;
                            if (ak < 5)
                                b1 = u;
                            else if (ak < 10)
                                b1 = fld_v_b;
                            else
                                b1 = fld_q_b;
                            a(0, Integer.toString(ak), ad2, b1);
                        } else {
                            ak = 1;
                        }
                        if (ck.B < 65) {
                            int id2 = Math.max(1, d5.B / 3);
                            int i4 = ak * c(b(id2) / 20);
                            aj += id2 + i4;
                        }
                        if (aj >= ck.B) {
                            aj -= ck.B;
                            d1.M[11] = 1500L + bR;
                            d1.I = 1;
                            ck.B = Math.min(65, ck.B + 14);
                            ck.a();
                            L.a(7);
                        }
                        if (ak > 1 && ai < inf_m.ab[T])
                            bS = bR + 2000L;
                        else if (ai == inf_m.ab[T])
                            bS = bR + 1000L;
                        L.a(1);
                        d2 = null;
                        if (H) {
                            int j4 = 55;
                            if ((ck.H & 0x200) != 0)
                                j4 += 20;
                            else if ((ck.H & 0x100) != 0)
                                j4 += 10;
                            j4 *= j4;
                            for (int j5 = 0; j5 < i1; j5++) {
                                cls_d d6;
                                if ((d6 = (cls_d) fld_m_Vector.elementAt(j5)).equals(ck) || d6.equals(d5) || d6.x || d6.B >= ck.B || (d6.H & 0x2000) != 0)
                                    continue;
                                int l1 = c(d6.o.a - ck.o.a);
                                int j2 = c(d6.o.b - ck.o.b);
                                int l2;
                                if ((l2 = l1 * l1 + j2 * j2) < j4) {
                                    d2 = d1;
                                    j4 = l2;
                                }
                            }

                        }
                        if (d2 == null) {
                            bT = 0L;
                            ck.c = null;
                            ck.d /= 3;
                            H = false;
                        }
                    } else if (d4.s == 18) {
                        int id2 = Math.max(1, d5.B >> 2);
                        if ((d4.H & 0x400) != 0)
                            id2 += 5;
                        else if ((d4.H & 0x200) != 0)
                            id2++;
                        if (d4.v && !B)
                            L.a(1);
                        d4.F = Math.min(d4.G, d4.F + id2);
                    }
                    if (d4.r != d5.r) {
                        if (d5.r == 28)
                            d5.a(d4);
                        d5.x = true;
                        if (d5.M[3] > bR) {
                            d4.b(0, 10000);
                            cls_aa ad2 = d1.o.a();
                            int k4 = 15 * g(192);
                            int k5 = 15 * f(192);
                            ad2.a(c(d1.o.a + k4), c(d1.o.b + k5), 25);
                            a(2, strs[262], ad2, fld_q_b);
                        }
                        if (d5.equals(cn))
                            cn = d4;
                    }
                }
            }
        }
    }

    final cls_d b(cls_d d1, int i1, int j1) {
        cls_d d2 = null;
        int k1 = fld_m_Vector.size();
        for (int l1 = 0; l1 < k1; l1++) {
            cls_d d3 = (cls_d) fld_m_Vector.elementAt(l1);
            if (!(d3).equals(d1) && !d3.x && ((j1 & 1) == 0 || d3.s != 0) && ((j1 & 2) == 0 || d3.r != 36) && ((j1 & 4) == 0 || d3.r != 37) && ((j1 & 8) == 0 || d3.B <= d1.B) && ((j1 & 0x10) == 0 || d3.M[0] <= bR) && ((j1 & 0x20) == 0 || d3.M[1] <= bR) && ((d3.H & 0x2000) == 0 || d3.s == 13)) {
                int j2;
                int i2 = (d3.o.a - d1.o.a) >> 8;
                j2 = (d3.o.b - d1.o.b) >> 8;
                if ((i2 = i2 * i2 + j2 * j2) < i1) {
                    d2 = d3;
                    i1 = i2;
                }
            }
        }

        return d2;
    }

    final void a(int i1, String s1, cls_aa aa1, cls_b b1) {
        Object aobj[];
        (aobj = new Object[4])[0] = new Integer(i1);
        aobj[1] = s1;
        aobj[2] = aa1;
        aobj[3] = b1;
        n.addElement(aobj);
    }

    private void c(cls_d d1, int i1, int j1) {
        int l1;
        int k1 = ((d1.o.a - ci.a) >> 8) % cz;
        l1 = ((d1.o.b - ci.b) >> 8) % cy;
        if (k1 < 0) {
            k1 += cz;
        }
        if (l1 < 0) {
            l1 += cy;
        }
        for (int i2 = 0; i2 < dr.length; i2++) {
            cls_u u1;
            if ((u1 = dt[i2]) != null) {
                int ai1[] = dr[i2];
                int k2 = (((ai1)[1] << 1) >> 1) - i1;
                int l2 = ((ai1[2] << 1) >> 1) - j1;
                int i3 = ai1[3];
                int j2 = ai1[4];
                if (k1 + d1.E > k2 + (i3 >> 2) && k1 - d1.E < (k2 + i3) - (i3 >> 2) && l1 + d1.E > l2 + (j2 >> 2) && l1 - d1.E < (l2 + j2) - (j2 >> 2)) {
                    if (u1.m < bR) {
                        u1.o = true;
                    }
                    if (u1.b == u1.i - 1) {
                        if (d1.s == 1) {
                            if ((d1.H & 0x1000) != 0) {
                                d1.x = true;
                            }
                        } else {
                            d1.f(15);
                        }
                    }
                }
            }
        }

    }

    final void a(Graphics g1) {
        if (dd > bP) {
            p.a(g1, strs[235], 88, 204, 33);
            return;
        }
        if (dd < bP - 800L)
            dd = bP + 800L;
    }

    public final void run() {
        repaint();
        serviceRepaints();
        setFullScreenMode(true);
        try {
            do {
                if (!z)
                    break;
                if (aS) {
                    sporeInstance.myThread = null;
                    return;
                }
                System.out.println("gameState = " + gameState);
                if (gameState == 1 && p == null) {
                    bufferImage = Image.createImage(DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT);
                    bufferGraphics = bufferImage.getGraphics();
                    p = new cls_b(11, 86, "", 0, r(4)); // TODO Check r() method
                    p.o = 141;
                    fld_q_b = new cls_b(11, 86, "", 0, r(0));
                    fld_q_b.o = p.o;
                    w = new cls_b(72, 88, "", 0);
                    w.o = p.o;
                    w.n += 3;
                    bD = new cls_u(115, 79);
                    bE = new cls_u(114, 76);
                    dk = 28;
                    i(8);
                }
                if (gameState == 0) {
                    cP++;
                    switch (cT) {
                        case 8:
                        case 142:
                            p();
                            break;

                        case 56:
                            r();
                            break;

                        case 31:
                            s();
                            break;

                        case 107:
                            u();
                            break;

                        case 17: // '\021'
                            t();
                            break;
                    }
                    if (gameState == cS)
                        w();
                } else {
                    if (aW && aU)
                        K.h();
                    if (cS != gameState) {
                        if (cS != 15 && gameState != 15) {
                            K.b_(cS);
                            K.d(gameState);
                        }
                        cU = 0;
                        if (gameState != 6 && gameState != 0 && gameState != 15)
                            N = -1;
                        if (gameState == 9)
                            y.a = new cls_h(this, (short) 6, (short) 1);
                        else if (gameState != 6 && gameState != 8 && gameState != 7 && gameState != 10 && gameState != 15)
                            y.a = new cls_h(this, (short) 6, (short) 6);
                        cS = gameState;
                    } else if (gameState != 0) {
                        de = bQ - bP;
                        bQ = System.currentTimeMillis();
                        if (de >= 66L) {
                            bP += de;
                            da = y.a.fld_q_short;
                            db = y.a.r;
                            switch (gameState) {
                                default:
                                    break;

                                case 7:
                                    bR += de;
                                    a(bufferGraphics, 0x3009e);
                                    d();
                                    K.b();
                                    break;

                                case 8:
                                    a(bufferGraphics, 0x1600c0);
                                    bR += de;
                                    ck.e(0);
                                    if (ck.o.a > ci.a - ((':') << 8)) {
                                        ci.a += (ck.o.a - (ci.a + ((':') << 8))) / 6;
                                    }
                                    if (ck.o.b > ci.b - (('\221') << 8)) {
                                        ci.b += (ck.o.b - (ci.b + (('\221') << 8))) / 6;
                                    }
                                    break;

                                case 9:
                                    L.d();
                                    K.c();
                                    break;

                                case 10:
                                    a(bufferGraphics, 4246);
                                    break;

                                case 11: // '\013'
                                    a(bufferGraphics, 150);
                                    int i1 = c(ck.o.a - ci.a);
                                    int j1;
                                    if ((j1 = c(ck.o.b - ci.b)) <= 0 || j1 >= DeviceInfo.DEVICE_SCREEN_HEIGHT || i1 <= 0 || i1 >= DeviceInfo.DEVICE_SCREEN_WIDTH)
                                        break;
                                    ck.v = true;
                                    cn = ck;
                                    gameState = 7;
                                    i1 = fld_m_Vector.size();
                                    for (int k1 = 0; k1 < i1; k1++) {
                                        cls_d d1 = (cls_d) fld_m_Vector.elementAt(k1);
                                        a(d1);
                                    }

                                    break;

                                case 13:
                                    cs.a(bP);
                                    if (cs.a != cs.c) {
                                        a(bufferGraphics, 0x30096);
                                        break;
                                    }
                                    if (cs.a != 0) {
                                        cs.a = cs.c = b(0);
                                        cj = new cls_aa(-DeviceInfo.DEVICE_SCREEN_WIDTH, 104);
                                        cj.b(0, 104, 6);
                                        ca = bP + 5600L;
                                    }
                                    if (cj.a >= b(DeviceInfo.DEVICE_SCREEN_WIDTH)) {
                                        if (R == 0) {
                                            k(4);
                                        } else {
                                            fld_m_Vector.removeAllElements();
                                            o.removeAllElements();
                                            k();
                                            y.b(25);
                                            O = 1;
                                            L.a(25);
                                        }
                                    } else {
                                        if (ca - 2800L < bP)
                                            cj.b(352, 104, 8);
                                        cj.b();
                                    }
                                    a(bufferGraphics, 8192);
                                    break;

                                case 12: // '\f'
                                    if (ca > bP) {
                                        if (ca - 1400L < bP)
                                            ct.a(bP);
                                        cj.b();
                                    }
                                    K.d();
                                    break;

                                case 14: // '\016'
                                    cs.a(bP);
                                    a(bufferGraphics, 32768);
                                    break;

                                case 6:
                                    if (aU) {
                                        d();
                                        a(bufferGraphics, 0x80096);
                                    } else if (N == 8 && R == 3)
                                        a(bufferGraphics, 0x100480);
                                    else if (N != -1 && N != 7 || y.a.a == 25 || y.a.fld_b_int == 6)
                                        a(bufferGraphics, 1154);
                                    else if (N == 7)
                                        a(bufferGraphics, 1158);
                                    else if (y.a.a == 19 || y.a.a == 17 && du == -1)
                                        a(bufferGraphics, 0x200480);
                                    else
                                        a(bufferGraphics, 1174);
                                    if (y.a.fld_b_int != 8 || as >= y.a.f)
                                        break;
                                    if (as == 0) {
                                        repaint();
                                        serviceRepaints();
                                    }
                                    bi[as] = a(bj[as]);
                                    as++;
                                    break;

                                case 1:
                                    k(4);
                                    if (Spore.d) {
                                        gameState = 5;
                                        i(142);
                                        recordManager.a = SplashScreen.a;    // TODO Check
                                    } else {
                                        y.b(19);
                                    }
                                    break;

                                case 2:
                                case 3:
                                case 4:
                                case 5:
                                    a(bufferGraphics, 54);
                                    if (bP > dc && gameState != 5) {
                                        dc = bP + 4100L;
                                        gameState++;
                                        dn = false;
                                    }
                                    break;

                                case 15:
                                    return;
                            }
                            Q++;
                            if (!cM) {
                                repaint();
                                serviceRepaints();
                            }
                            if (gameState == cS) {
                                w();
                                super.c = true;
                                MainThread ac1;
                                if (((ac1 = this).keyStats & ac1.a) != 0) {
                                    ac1.keyStats &= ~ac1.a;
                                    if (ac1.fld_b_int != 0)
                                        ac1.fld_e_int = ac1.fld_b_int;
                                    ac1.fld_b_int = 0;
                                    ac1.a = 0;
                                }
                            }
                            if (cW) {
                                if (L.d)
                                    try {
                                        Thread.sleep(200L);
                                    }
                                    catch (Exception _ex) {
                                    }
                                L.d = false;
                                cW = false;
                            }
                        }
                    }
                }
            } while (true);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        Spore.a();
        sporeInstance.notifyDestroyed();
    }

    final int j(int i1) {
        if (i1 != 0)
            return (cR.nextInt() >>> 1) % i1;
        else
            return 0;
    }

    final void a(cls_d d1) {
        if (R == 1 && d1.r != 19 && d1.r != 38 && d1.r != 41) {
            if (d1.o.a < 0 && !cls_d.c(d1.fld_m_int))
                d1.o.a = 45056;
            else if (d1.o.a > 45056 && !cls_d.d(d1.fld_m_int))
                d1.o.a = 0;
            if (d1.o.b < 0 && !cls_d.b(d1.fld_m_int))
                d1.o.b = 47616;
            else if (d1.o.b > 47616 && !cls_d.a(d1.fld_m_int))
                d1.o.b = 0;
        }
        int i1;
        int j1;
        if (d1.r != 35) {
            if (d1.h != null) {
                i1 = d1.h.c;
                j1 = d1.h.d;
            } else if (d1.i != null) {
                i1 = d1.i.f;
                j1 = d1.i.g;
            } else {
                i1 = j1 = d1.B;
            }
        } else {
            i1 = j1 = 110;
        }
        i1 >>= 1;
        j1 >>= 1;
        if (d1.s == 1 || d1.s == 12 || d1.s == 8) {
            int l2;
            int k1 = (d1.q[d1.q.length - 1].a - ci.a) >> 8;
            if ((l2 = (d1.q[d1.q.length - 1].b - ci.b) >> 8) + j1 > 0) {
                if (l2 - j1 < DeviceInfo.DEVICE_SCREEN_HEIGHT) {
                    if (k1 + i1 > 0) {
                        if (k1 - i1 < DeviceInfo.DEVICE_SCREEN_WIDTH) {
                            d1.v = true;
                            return;
                        }
                    }
                }
            }
        }
        int i3;
        int l1 = (d1.o.a - ci.a) >> 8;
        if ((i3 = (d1.o.b - ci.b) >> 8) + (j1 + (j1 >> 1)) > 0) {
            if (i3 - (j1 + (j1 >> 1)) < DeviceInfo.DEVICE_SCREEN_HEIGHT) {
                if (l1 + (i1 + (i1 >> 1)) > 0 && l1 - (i1 + (i1 >> 1)) < DeviceInfo.DEVICE_SCREEN_WIDTH) {
                    d1.v = true;
                } else {
                    if (d1.s == 9 || d1.s == 19 || d1.s == 22) {
                        d1.x = true;
                        return;
                    }
                    if (d1.s == 18 && d1.c != null)
                        return;
                    d1.v = false;
                    int l3 = DeviceInfo.DEVICE_SCREEN_WIDTH;
                    int i4 = DeviceInfo.DEVICE_SCREEN_HEIGHT;
                    int j4;
                    cls_aa aj4 = cn.o;
                    if (R == 2 && d1.s != 18) {
                        cls_q q1 = (cls_q) K;
                        int j3;
                        int i2 = (d1.o.a - q1.a.o.a) >> 8;
                        j3 = (d1.o.b - q1.a.o.b) >> 8;
                        j4 = i2 * i2 + j3 * j3;
                        i2 = (d1.o.a - q1.fld_b_d.o.a) >> 8;
                        j3 = (d1.o.b - q1.fld_b_d.o.b) >> 8;
                        i2 = i2 * i2 + j3 * j3;
                        j3 = (j3 = Math.min(DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT)) * j3;
                        if (j4 < j3 || i2 < j3)
                            return;
                        if (j(2) == 0)
                            aj4 = q1.a.o;
                        else
                            aj4 = q1.fld_b_d.o;
                    }

                    if (d1.o.a > aj4.a + ('\260' << 8) || d1.o.a < aj4.a - ('\260' << 8) || d1.o.b > aj4.b + ('\320' << 8) || d1.o.b < aj4.b - ('\320' << 8)) {
                        if (d1.s == 18)
                            if (d1.r == 36)
                                d1.c = ((cls_q) K).fld_b_d;
                            else
                                d1.c = ((cls_q) K).a;
                        int k4 = 10;
                        do {
                            int k3;
                            int j2 = (j(l3 << 1) - l3) << 8;
                            k3 = (j(i4 << 1) - i4) << 8;
                            d1.o.a = aj4.a + j2;
                            d1.o.b = aj4.b + k3;
                            j2 = (d1.o.a - ci.a) >> 8;
                            k3 = (d1.o.b - ci.b) >> 8;
                            d1.v = k3 + j1 > 0 && k3 - j1 < DeviceInfo.DEVICE_SCREEN_HEIGHT && j2 + i1 > 0 && j2 - i1 < DeviceInfo.DEVICE_SCREEN_WIDTH;
                            k4--;
                            if (d1.v && k4 == 0) {
                                k4 = 10;
                                l3 += l3 >> 2;
                                i4 += i4 >> 2;
                            }
                        } while (d1.v);
                        if (d1.q != null) {
                            for (int k2 = 0; k2 < d1.q.length; k2++) {
                                d1.q[k2].a = d1.o.a;
                                d1.q[k2].b = d1.o.b;
                            }

                        }
                    }
                }
            } else {
                if (d1.s == 9 || d1.s == 19 || d1.s == 22) {
                    d1.x = true;
                    return;
                }
                if (d1.s == 18 && d1.c != null)
                    return;
                d1.v = false;
                int l3 = DeviceInfo.DEVICE_SCREEN_WIDTH;
                int i4 = DeviceInfo.DEVICE_SCREEN_HEIGHT;
                int j4;
                cls_aa aj4 = cn.o;
                if (R == 2 && d1.s != 18) {
                    cls_q q1 = (cls_q) K;
                    int j3;
                    int i2 = (d1.o.a - q1.a.o.a) >> 8;
                    j3 = (d1.o.b - q1.a.o.b) >> 8;
                    j4 = i2 * i2 + j3 * j3;
                    i2 = (d1.o.a - q1.fld_b_d.o.a) >> 8;
                    j3 = (d1.o.b - q1.fld_b_d.o.b) >> 8;
                    i2 = i2 * i2 + j3 * j3;
                    j3 = (j3 = Math.min(DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT)) * j3;
                    if (j4 < j3 || i2 < j3)
                        return;
                    if (j(2) == 0)
                        aj4 = q1.a.o;
                    else
                        aj4 = q1.fld_b_d.o;
                }

                if (d1.o.a > aj4.a + ('\260' << 8) || d1.o.a < aj4.a - ('\260' << 8) || d1.o.b > aj4.b + ('\320' << 8) || d1.o.b < aj4.b - ('\320' << 8)) {
                    if (d1.s == 18)
                        if (d1.r == 36)
                            d1.c = ((cls_q) K).fld_b_d;
                        else
                            d1.c = ((cls_q) K).a;
                    int k4 = 10;
                    do {
                        int k3;
                        int j2 = (j(l3 << 1) - l3) << 8;
                        k3 = (j(i4 << 1) - i4) << 8;
                        d1.o.a = aj4.a + j2;
                        d1.o.b = aj4.b + k3;
                        j2 = (d1.o.a - ci.a) >> 8;
                        k3 = (d1.o.b - ci.b) >> 8;
                        d1.v = k3 + j1 > 0 && k3 - j1 < DeviceInfo.DEVICE_SCREEN_HEIGHT && j2 + i1 > 0 && j2 - i1 < DeviceInfo.DEVICE_SCREEN_WIDTH;
                        k4--;
                        if (d1.v && k4 == 0) {
                            k4 = 10;
                            l3 += l3 >> 2;
                            i4 += i4 >> 2;
                        }
                    } while (d1.v);
                    if (d1.q != null) {
                        for (int k2 = 0; k2 < d1.q.length; k2++) {
                            d1.q[k2].a = d1.o.a;
                            d1.q[k2].b = d1.o.b;
                        }

                    }
                }
            }
        } else {
            if (d1.s == 9 || d1.s == 19 || d1.s == 22) {
                d1.x = true;
                return;
            }
            if (d1.s == 18 && d1.c != null)
                return;
            d1.v = false;
            int l3 = DeviceInfo.DEVICE_SCREEN_WIDTH;
            int i4 = DeviceInfo.DEVICE_SCREEN_HEIGHT;
            int j4;
            cls_aa aj4 = cn.o;
            if (R == 2 && d1.s != 18) {
                cls_q q1 = (cls_q) K;
                int j3;
                int i2 = (d1.o.a - q1.a.o.a) >> 8;
                j3 = (d1.o.b - q1.a.o.b) >> 8;
                j4 = i2 * i2 + j3 * j3;
                i2 = (d1.o.a - q1.fld_b_d.o.a) >> 8;
                j3 = (d1.o.b - q1.fld_b_d.o.b) >> 8;
                i2 = i2 * i2 + j3 * j3;
                j3 = (j3 = Math.min(DeviceInfo.DEVICE_SCREEN_WIDTH, DeviceInfo.DEVICE_SCREEN_HEIGHT)) * j3;
                if (j4 < j3 || i2 < j3)
                    return;
                if (j(2) == 0)
                    aj4 = q1.a.o;
                else
                    aj4 = q1.fld_b_d.o;
            }

            if (d1.o.a > aj4.a + ('\260' << 8) || d1.o.a < aj4.a - ('\260' << 8) || d1.o.b > aj4.b + ('\320' << 8) || d1.o.b < aj4.b - ('\320' << 8)) {
                if (d1.s == 18)
                    if (d1.r == 36)
                        d1.c = ((cls_q) K).fld_b_d;
                    else
                        d1.c = ((cls_q) K).a;
                int k4 = 10;
                do {
                    int k3;
                    int j2 = (j(l3 << 1) - l3) << 8;
                    k3 = (j(i4 << 1) - i4) << 8;
                    d1.o.a = aj4.a + j2;
                    d1.o.b = aj4.b + k3;
                    j2 = (d1.o.a - ci.a) >> 8;
                    k3 = (d1.o.b - ci.b) >> 8;
                    d1.v = k3 + j1 > 0 && k3 - j1 < DeviceInfo.DEVICE_SCREEN_HEIGHT && j2 + i1 > 0 && j2 - i1 < DeviceInfo.DEVICE_SCREEN_WIDTH;
                    k4--;
                    if (d1.v && k4 == 0) {
                        k4 = 10;
                        l3 += l3 >> 2;
                        i4 += i4 >> 2;
                    }
                } while (d1.v);
                if (d1.q != null) {
                    for (int k2 = 0; k2 < d1.q.length; k2++) {
                        d1.q[k2].a = d1.o.a;
                        d1.q[k2].b = d1.o.b;
                    }

                }
            }
        }
        if (d1.r == 27 && !d1.v && d1.O > 0 && d1.a != null && d1.a.v)
            d1.v = true;
    }

    final void k(int i1) {
        l();
        if (R != i1) {
            K.a(i1);
            cls_w w1;
            for (int j1 = (w1 = K).K; j1 < w1.L; j1++)
                w1.I.b[j1] = null;

            K.an = true;
            fld_m_Vector.removeAllElements();
            k();
        }
        if ((i1 == 0 || i1 == 3) && R != 0 && R != 3)
            dk = 36;
        switch (R = i1) {
            default:
                break;

            case 0:
                gameState = 9;
                i(56);
                break;

            case 1:
                gameState = 9;
                i(107);
                y.d();
                break;

            case 3:
                gameState = 8;
                i(31);
                break;

            case 2:
                i(17);
                break;

            case 4:
                if (K.an) {
                    K = null;
                    K = new cls_w(this);
                    L.d();
                    L.a(27, true);
                    K.a();
                }
                if (gameState != 1) {
                    y.d();
                    y.c();
                    y.b(0);
                }
                break;
        }
        y.c();
    }

    final void l(int i1) {
        B = false;
        K.vector.removeAllElements();
        n.removeAllElements();
        fld_m_Vector.removeAllElements();
        o.removeAllElements();
        cn = null;
        a(ck, 0, 0);
        switch (i1) {
            case 0:
                if (recordManager.d == 0) {
                    a(ck, cA);
                    recordManager.a(0);
                } else {
                    a(ck, recordManager.i);
                }
                ch = recordManager.k;
                break;

            case 1:
                ch = recordManager.l;
                if (recordManager.e == 0)
                    recordManager.a(1);
                break;

            case 2:
                L.d();
                K.a();
                l();
                y.d();
                break;
        }
        if (i1 == 0 || i1 == 1) {
            cf = new int[ch.length];
            ce = new int[ch.length];
            cg = new int[ch.length];
            System.arraycopy(ch, 0, cg, 0, ch.length);
        }
    }

    private void r() {
        switch (cP) {
            case 0:
                i();
                return;

            case 1:     // Select Game mode
                if (K.an) {
                    K = null;
                    K = new cls_j(this);
                }
                y.d();
                a();
                return;

            case 3:
                T = recordManager.d;
                c();
                a();
                return;

            case 4:
                K.a();
                return;

            case 5:
                ck.o = new cls_aa(88, 104);
                ck.fld_m_int = ck.l = 0;
                ck.v = true;
                ck.x = false;
                ck.c = null;
                ck.D = 0;
                ck.B += T;
                ck.a();
                a();
                A = false;
                al = 0;
                ci.a = 0;
                ci.b = 0;
                ar = recordManager.k[5];
                return;

            case 6:
                b();
                // fall through

            case 2:
            default:
                return;
        }
    }

    private void s() {
        switch (cP) {
            case 0:
                ci.a = 0;
                ci.b = 0;
                a();
                fld_m_Vector.removeAllElements();
                cn = null;
                i();
                for (int i1 = 0; i1 < 190; i1++)
                    imageResources[i1] = null;

                a();
                return;

            case 1:
                if (K.an) {
                    K = null;
                    K = j = new cls_f(this);
                }
                a();
                return;

            case 2:
                cls_f f1;
                (f1 = j).img40 = loadUnencodeImage(40);
                f1.mainThread.a();
                f1.img43 = loadUnencodeImage(43);
                f1.mainThread.a();
                f1.mainThread.a();
                f1.img53 = loadUnencodeImage(53);
                f1.mainThread.a();
                f1.img63 = loadUnencodeImage(63);
                f1.mainThread.a();
                f1.mainThread.a();
                f1.img54 = loadUnencodeImage(54);
                f1.mainThread.a();
                f1.img44 = loadUnencodeImage(44);
                f1.mainThread.a();
                f1.img100 = loadUnencodeImage(100);
                f1.mainThread.a();
                f1.mainThread.a();
                f1.B = new cls_u(110, 84);
                f1.mainThread.a();
                f1.D = new cls_k(47, 3);
                f1.mainThread.a();
                f1.mainThread.a();
                f1.C = new cls_k(42, 6);
                f1.mainThread.a();
                f1.E = new cls_k(48, 6);
                f1.mainThread.a();
                f1.mainThread.a();
                f1.y = new cls_u(41, 91);
                f1.z = new cls_u(41, 91, f1.mainThread.r(15));
                f1.A = new cls_u(41, 91, f1.mainThread.r(16));
                f1.mainThread.a();
                f1.F = new cls_a(107, 81, f1.mainThread.r(24));
                f1.mainThread.a();
                return;

            case 3:
                j.a(ck);
                a();
                cls_f f2 = j;
                (f2).j[0] = f2.q.L[0].c / 5;
                f2.j[1] = f2.q.L[1].c / 5;
                f2.j[2] = f2.q.L[2].c / 5;
                f2.q.o = new cls_aa(88, 104);
                f2.q.fld_m_int = 192;
                f2.q.l = 192;
                f2.q.B = 65;
                f2.q.a();
                f2.mainThread.a();
                f2.k = true;
                int j1 = 0;
                do {
                    if (j1 >= 12)
                        break;
                    if (f2.b(j1) == 0) {
                        f2.k = false;
                        break;
                    }
                    j1++;
                } while (true);
                j1 = f2.mainThread.recordManager.d / 3 != 0 ? f2.mainThread.recordManager.d / 3 + 1 : f2.mainThread.recordManager.d - 1;
                if (!f2.mainThread.recordManager.c && j1 < f2.G.length)
                    f2.e = 0;
                else
                    f2.e = f2.mainThread.recordManager.u;
                f2.mainThread.a();
                f2.f = -1;
                f2.g = 0;
                if (f2.i == null) {
                    f2.i = new int[4];
                    f2.h = new int[4];
                    j1 = f2.y.g;
                    f2.c = 3 + (j1 >> 1);
                    for (int k1 = 0; k1 < 4; k1++)
                        f2.i[k1] = 18 + k1 * 34;

                    for (int l1 = 0; l1 < 4; l1++)
                        f2.h[l1] = f2.c + l1 * j1;

                }
                f2.mainThread.a();
                f2.a = f2.d / 3;
                f2.fld_b_int = f2.d % 3;
                f2.m = new cls_aa(0, DeviceInfo.DEVICE_SCREEN_HEIGHT);
                f2.mainThread.a();
                f2.l = new cls_aa(0, -86);
                f2.mainThread.a();
                f2.n = new cls_aa(149, 0);
                f2.mainThread.a();
                f2.o = new cls_aa(14, 91 + f2.mainThread.u.n);
                f2.p = new cls_aa((f2.n.a >> 8) + 24 + 3, (f2.n.b >> 8) + 14 + 1);
                a();
                return;

            case 4:
                b();
                break;
        }
    }

    private void t() {
        switch (cP) {
            case 0:
                if (K.an) {
                    K = null;
                    K = new cls_q(this);
                }
                a();
                return;

            case 1:
                cls_q q1 = (cls_q) K;
                if (aZ != null) {
                    q1.c = new String[2][];
                    cls_q.a(aZ, q1.c);
                    aZ = null;
                }
                a();
                if (ba != null) {
                    q1.d = new String[9][];
                    cls_q.a(ba, q1.d);
                    ba = null;
                }
                a();
                return;

            case 2:
                K.g();
                a();
                return;

            case 3:
                b();
                break;
        }
    }

    private void u() {
        switch (cP) {
            case 0:
                cr = -1;
                i();
                return;

            case 1:
                if (K.an) {
                    K = null;
                    K = new cls_n(this);
                }
                a();
                return;

            case 2:
                T = recordManager.e;
                U = (T / 3) % 6;
                if (T == 0) {
                    a(ck, cA);
                    j = new cls_f(this);
                    j.a(ck);
                    j.c(5);
                    j = null;
                    a();
                    ck.H |= 0x200;
                    ck.a(0, 512, 224, 0);
                    ck.a(0, 512, 32, 0);
                    ck.d();
                    a();
                    recordManager.h = b(ck);
                    return;
                } else {
                    a(ck, recordManager.h);
                    return;
                }

            case 3:
                a(ck, 7, 0);
                a();
                ck.o = new cls_aa(88, 104);
                ck.fld_m_int = ck.l = 0;
                ck.v = true;
                ck.x = false;
                ck.c = null;
                ck.D = 0;
                ck.G = 17;
                ck.F = 17 - recordManager.f;
                ck.e = ck.U[0] + ((1 << 8) / 2 * ck.U[0] >> 8);
                ck.A = 64;
                cF = bR + 1000L;
                a();
                return;

            case 4:
                b();
                break;
        }
    }

    private void v() {
        int ai1[] = r(0);
        int ai2[] = r(1);
        int ai3[] = r(2);
        int ai4[] = r(3);
        a();
        r = new cls_b(11, 86, "", 0, ai2);
        r.o = p.o;
        a();
        s = new cls_b(11, 86, "", 0, ai3);
        s.o = p.o;
        a();
        t = new cls_b(11, 86, "", 0, ai4);
        t.o = p.o;
        a();
        u = new cls_b(19, 87, "", 0);
        fld_v_b = new cls_b(19, 87, "", 0, ai1);
        a();
        u.o = p.o;
        fld_v_b.o = u.o;
        a();
        x = new cls_b(72, 88, "", 0, ai1);
        x.o = w.o;
        x.n += 3;
        a();
    }

    final void e() {
        if (gameState == 6 || gameState == 1 || gameState == 0 || gameState == 4 || gameState == 5 || gameState == 12 || gameState == 15 || gameState == 14 || gameState == 13 || gameState != cS)
            return;
        N = cS;
        cls_ab ab1;
        if ((ab1 = L).c != null) {
            ab1.a();
            for (int i1 = 0; i1 < ab1.c.length; i1++)
                if (ab1.c[i1] != null && ab1.c[i1].c == 2)
                    ab1.b.b(ab1.c[i1]);

            ab1.e = -1;
            ab1.b.b = false;
        }
        if (gameState != 15) {
            aT = true;
            y.b(5);
        }
    }

    final void f() {
        if (N == 6)
            gameState = 7;
        else
            gameState = N;
        aT = false;
        cls_ab ab1;
        if (R != 3 && (ab1 = L).c != null && !ab1.mainThread.aT && ab1.mainThread.recordManager.a) {
            for (int i1 = 0; i1 < ab1.c.length; i1++) {
                if (ab1.c[i1] == null)
                    continue;
                ab1.b.a(ab1.c[i1].b, 100);
                if (ab1.c[i1].c == 1) {
                    ab1.b.c(ab1.c[i1]);
                    ab1.e = i1;
                }
            }

        }
    }

    final Image a(String s1) {
//        s1 = 0;
//        s1 = 0;
//        s1 = 28;
//        s1 = 42;
//        Object obj = s1;
//        s1 = this;
        cls_d d1 = new cls_d(this, 36, 0, 0);
        this.a(d1, (s1));
        Graphics g1;
        Object obj = Image.createImage(38, 24);
        (g1 = ((Image) (obj)).getGraphics()).setColor(0);
        g1.fillRect(0, 0, 38, 24);
        cls_aa aa1 = new cls_aa(-19, -12);
        d1.fld_m_int = 0;
        d1.a(g1, aa1);
        this.a(d1, 3, 0);
        return ((Image) (obj));
    }

    final void g() {
        bi = null;
    }

    final void h() {
        L.d();
        Spore.a();
    }

    private void w() {
        if (aU && (super.fld_e_int & 0x40000) == 0) {
            super.fld_e_int = super.keyStats = 0;
            return;
        }
        MainThread ac1 = this;
        int i1 = (ac1).getKeyStates();
        if (((i1) & 2) == 0) {
            ac1.a(2);
            ac1.a(512);
        }
        if ((i1 & 0x40) == 0) {
            ac1.a(4);
            ac1.a(32768);
        }
        if ((i1 & 4) == 0) {
            ac1.a(8);
            ac1.a(2048);
        }
        if ((i1 & 0x20) == 0) {
            ac1.a(16);
            ac1.a(8192);
        }
        if ((i1 & 0x100) == 0) {
            ac1.a(32);
            ac1.a(4096);
        }
        switch (gameState) {
            case 11: // '\013'
            case 13:
            default:
                break;

            case 7:
                K.a(super.fld_e_int, super.keyStats);
                if (dz == 6)
                    if (cI && R == 0 && super.fld_e_int != 0) {
                        if ((super.fld_e_int & 0x40000) != 0) {
                            B = true;
                            gameState = 12;
                        }
                        cI = false;
                    } else if ((super.fld_e_int & 0x100000) != 0)
                        cI = true;
                if ((super.fld_e_int & 0x40) != 0 || (super.fld_e_int & 0x40000) != 0)
                    e();
                break;

            case 8:
                K.a(super.fld_e_int, super.keyStats);
                break;

            case 14: // '\016'
                if ((super.fld_e_int & 0x1020) != 0) {
                    K.e();
                    o();
                } else if ((super.fld_e_int & 0x40) != 0) {
                    K.f();
                    o();
                }
                if (dB <= 1)
                    break;
                if ((super.fld_e_int & 0x202) != 0) {
                    if (--dA < 0)
                        dA = 0;
                    break;
                }
                if ((super.fld_e_int & 0x8004) != 0 && ++dA == dB)
                    dA = dB - 1;
                break;

            case 12: // '\f'
                if ((super.fld_e_int & 0x40) != 0 && R != 2) {
                    ca = 0L;
                    L.b(24);
                }
                break;

            case 9:
                if ((super.fld_e_int & 0x1020) != 0) {
                    char c1 = '\u0100';
                    cs.a = (c1) << 8;
                    cs.a(0, 0, 0L, bP);
                    an = -1;
                    if (!recordManager.c && !K.e())
                        gameState = 10;
                    else
                        gameState = 11;
                    break;
                }
                if ((super.fld_e_int & 0x40) != 0 || (super.fld_e_int & 0x40000) != 0) {
                    e();
                    break;
                }
                if (dz == 6 && (super.fld_e_int & 0x10) != 0) {
                    B = true;
                    gameState = 12;
                }
                break;

            case 10:
                if ((super.fld_e_int & 0x20000) != 0 || (super.fld_e_int & 0x1020) != 0) {
                    y.a = new cls_h(this, (short) 5, (short) 4);
                    if (K.e()) {
                        cn = ck;
                        gameState = 11;
                    }
                    break;
                }
                if (((super.fld_e_int & 0x40000) != 0 || (super.fld_e_int & 0x40) != 0) && R != 1) {
                    if (an > 0) {
                        K.f();
                        if (an == 0)
                            y.a = new cls_h(this, (short) 5, (short) 2);
                    } else {
                        cn = ck;
                        gameState = 11;
                    }
                    break;
                }
                if (R == 1 && (super.fld_e_int & 0x40) != 0) {
                    cn = ck;
                    gameState = 11;
                }
                break;

            case 6:  // Enter Game senc
                if (super.fld_e_int != 0)
                    K.b(super.fld_e_int, y.a.a);
                if (y.a.a == 19) {
                    if (dz < 6 && (super.fld_e_int & inf_m.ae[dz]) != 0)
                        dz++;
                    break;
                }
                if (dz != 6)
                    break;
                if (cI && super.fld_e_int != 0 && R == 4) {
                    byte byte0 = 50;
                    int j1 = co.size();
                    if ((super.fld_e_int & 0x80000) != 0)
                        byte0 = 0;
                    else if ((super.fld_e_int & 0x80) != 0 && !aW)
                        byte0 = 36;
                    if (byte0 != 50 && j1 < 15) {
                        String s1;
                        do
                            s1 = j();
                        while (co.contains(s1));
                        co.addElement(s1);
                        cp.addElement(new Integer(byte0));
                        recordManager.g();
                    }
                    cI = false;
                    break;
                }
                if ((super.fld_e_int & 0x100000) != 0 && R == 4)
                    cI = true;
                break;

            case 5:   // Splash ok, click enter
                if ((super.fld_e_int & 0x20) != 0)
                    y.b(0);
                break;
        }
        super.fld_e_int = 0;
    }

    final int m(int i1) {
        if ((super.keyStats & 0x202) != 0 || (super.keyStats & 0x100) != 0 || (super.keyStats & 0x400) != 0) {
            if ((super.keyStats & 0x808) != 0 || (super.keyStats & 0x100) != 0)
                return 160;
            return (super.keyStats & 0x2010) == 0 && (super.keyStats & 0x400) == 0 ? 192 : 224;
        }
        if ((super.keyStats & 0x8004) != 0 || (super.keyStats & 0x4000) != 0 || (super.keyStats & 0x10000) != 0) {
            if ((super.keyStats & 0x808) != 0 || (super.keyStats & 0x4000) != 0)
                return 96;
            return (super.keyStats & 0x2010) == 0 && (super.keyStats & 0x10000) == 0 ? 64 : 32;
        }
        if ((super.keyStats & 0x808) != 0)
            return 128;
        if ((super.keyStats & 0x2010) != 0)
            return 0;
        else
            return i1;
    }

    private void x() {
        long l1 = System.currentTimeMillis();
        dc = l1 + 4100L;
        dd = l1 + 800L;
    }

    final void n(int i1) {
        switch (i1) {
            case 19: // '\023'
            case 36: // '$'
            case 37: // '%'
            case 38: // '&'
            case 39: // '\''
            case 40: // '('
            case 41: // ')'
            default:
                break;

            case 2:
                if (at[0] != null)
                    break;
                if (U == 2) {
                    at[0] = new cls_a(116, 24, r(18));
                    return;
                } else {
                    at[0] = new cls_a(116, 24);
                    return;
                }

            case 3:
                if (at[1] != null)
                    break;
                if (U == 2) {
                    at[1] = new cls_a(117, 25, r(18));
                    return;
                } else {
                    at[1] = new cls_a(117, 25);
                    return;
                }

            case 4:
                if (at[2] != null)
                    break;
                if (U == 2) {
                    at[2] = new cls_a(118, 26, r(18));
                    return;
                } else {
                    at[2] = new cls_a(118, 26);
                    return;
                }

            case 21: // '\025'
                if (au[0] == null) {
                    au[0] = new cls_a(119, 27);
                    return;
                }
                break;

            case 22: // '\026'
                if (au[1] == null) {
                    au[1] = new cls_a(120, 28);
                    return;
                }
                break;

            case 23: // '\027'
                if (au[2] == null) {
                    au[2] = new cls_a(121, 29);
                    return;
                }
                break;

            case 5:
                if (be == null) {
                    be = new cls_a(123, 30);
                    bc = new cls_a(112, 78);
                    return;
                }
                break;

            case 6:
                if (bg == null) {
                    bg = new cls_a(122, 37);
                    return;
                }
                break;

            case 10:
                if (az[0] == null) {
                    az[0] = new cls_a(107, 81, r(23));
                    av[0] = new cls_a(127, 31, r(21));
                    aw[0] = new cls_a(127, 31, r(22));
                    aA[0] = new cls_a(107, 81, r(24));
                    return;
                }
                break;

            case 11: // '\013'
                if (az[1] == null) {
                    az[1] = new cls_a(108, 82, r(23));
                    av[1] = new cls_a(128, 32, r(21));
                    aw[1] = new cls_a(128, 32, r(22));
                    aA[1] = new cls_a(108, 82, r(24));
                    return;
                }
                break;

            case 12: // '\f'
                if (az[2] == null) {
                    az[2] = new cls_a(109, 83, r(23));
                    av[2] = new cls_a(129, 33, r(21));
                    aw[2] = new cls_a(129, 33, r(22));
                    aA[2] = new cls_a(109, 83, r(24));
                    return;
                }
                break;

            case 7:
                if (ax[0] == null) {
                    ax[0] = new cls_a(124, 21);
                    return;
                }
                break;

            case 8:
                if (ax[1] == null) {
                    ax[1] = new cls_a(125, 22);
                    return;
                }
                break;

            case 9:
                if (ax[2] == null) {
                    ax[2] = new cls_a(126, 23);
                    return;
                }
                break;

            case 13:
                if (img92 == null) {
                    img92 = loadUnencodeImage(92);
                    return;
                }
                break;

            case 14: // '\016'
                if (img91 == null) {
                    img91 = loadUnencodeImage(91);
                    return;
                }
                break;

            case 15:
                if (img90 == null) {
                    img90 = loadUnencodeImage(90);
                    return;
                }
                break;

            case 16:
                if (ay[0] == null) {
                    ay[0] = new cls_a(146, 34);
                    return;
                }
                break;

            case 17: // '\021'
                if (ay[1] == null) {
                    ay[1] = new cls_a(147, 35);
                    return;
                }
                break;

            case 18: // '\022'
                if (ay[2] == null) {
                    ay[2] = new cls_a(148, 36);
                    return;
                }
                break;

            case 27:
                if (bf == null)
                    bf = new cls_a(165, 65);
                break;

            case 28:
                if (img76 == null) {
                    img76 = loadUnencodeImage(76);
                    return;
                }
                break;

            case 29:
                if (bM[0] == null)
                    bM[0] = new cls_u(153, 73);
                if (aK[0] != null)
                    break;
                if (U == 2) {
                    aK[0] = a(14, r(20));
                    return;
                } else {
                    aK[0] = loadUnencodeImage(14);
                    return;
                }

            case 30: // '\036'
                if (bM[1] == null)
                    bM[1] = new cls_u(154, 74);
                if (aK[1] != null)
                    break;
                if (U == 2) {
                    aK[1] = a(15, r(20));
                    return;
                } else {
                    aK[1] = loadUnencodeImage(15);
                    return;
                }

            case 31:
                if (bM[2] == null)
                    bM[2] = new cls_u(155, 75);
                if (aK[2] != null)
                    break;
                if (U == 2) {
                    aK[2] = a(16, r(20));
                    return;
                } else {
                    aK[2] = loadUnencodeImage(16);
                    return;
                }

            case 32:
                if (iceImages[0] == null)
                    iceImages[0] = loadUnencodeImage(33);
                if (img36 == null) {
                    img36 = loadUnencodeImage(36);
                    return;
                }
                break;

            case 33: // '!'
                if (iceImages[1] == null)
                    iceImages[1] = loadUnencodeImage(34);
                if (img36 == null) {
                    img36 = loadUnencodeImage(36);
                    return;
                }
                break;

            case 34:
                if (iceImages[2] == null)
                    iceImages[2] = loadUnencodeImage(35);
                if (img36 == null) {
                    img36 = loadUnencodeImage(36);
                    return;
                }
                break;

            case 35:
                if (bh == null) {
                    bh = new cls_a(149, 38);
                    return;
                }
                break;

            case 20: // '\024'
                if (bN == null) {
                    bN = new cls_u(156, 56);
                    bN.j = 3;
                    bN.l = 250;
                    bO = new cls_u(157, 57);
                    bO.j = 3;
                    bO.l = 250;
                    bO.b = bO.i - 1 >> 1;
                    return;
                }
                break;

            case 24: // '\030'
                if (img94 == null) {
                    img94 = loadUnencodeImage(94);
                    return;
                }
                break;

            case 25: // '\031'
                if (img93 == null) {
                    img93 = loadUnencodeImage(93);
                    return;
                }
                break;

            case 26: // '\032'
                if (img95 == null) {
                    img95 = loadUnencodeImage(95);
                    return;
                }
                break;

            case 42:
                if (bB == null) {
                    bB = new cls_u(98, 90);
                    return;
                }
                break;

            case 43:
                if (bk[0] == null) {
                    bk[0] = new cls_k(5, 2);
                    return;
                }
                break;

            case 44:
                if (bk[1] == null) {
                    bk[1] = new cls_k(6, 8);
                    return;
                }
                break;

            case 45:
                if (bk[2] == null) {
                    bk[2] = new cls_k(7, 2);
                    return;
                }
                break;

            case 46:
                if (bk[3] == null) {
                    bk[3] = new cls_k(8, 3);
                    return;
                }
                break;

            case 47:
                if (bk[4] == null) {
                    bk[4] = new cls_k(9, 4);
                    return;
                }
                break;

            case 48:
                if (bk[5] == null) {
                    bk[5] = new cls_k(10, 4);
                    return;
                }
                break;

            case 49:
                if (bk[6] == null)
                    bk[6] = new cls_k(45, 4);
                break;
        }
    }

    final void i() {
        for (int i1 = 0; i1 < 3; i1++) {
            at[i1] = null;
            ax[i1] = null;
            au[i1] = null;
            av[i1] = null;
            aw[i1] = null;
            ay[i1] = null;
            aK[i1] = null;
            bM[i1] = null;
            az[i1] = null;
            aA[i1] = null;
            iceImages[i1] = null;
            a();
        }

        be = null;
        bc = null;
        img92 = null;
        img91 = null;
        img90 = null;
        bf = null;
        bg = null;
        img76 = null;
        img94 = null;
        img93 = null;
        img95 = null;
        img36 = null;
        bN = null;
        bO = null;
        bB = null;
        a();
        if (R != 1) {
            for (int j1 = 0; j1 < 7; j1++)
                bk[j1] = null;

        }
        a();
    }

    final void o(int i1) {
        int j1 = fld_m_Vector.size();
        int k1 = 0;
        for (int l1 = 0; k1 < j1 && l1 < i1; k1++) {
            cls_d d1;
            if ((d1 = (cls_d) fld_m_Vector.elementAt(k1)).s == 1 && !d1.v && !d1.x && (d1.H & 0x1000) == 0) {
                d1.x = true;
                l1++;
            }
        }

    }

    final String j() {
        j = new cls_f(this);
        cls_d d1 = new cls_d(this, 0, 0, 0);
        for (int i1 = 0; i1 < 5; i1++) {
            j.a(d1);
            j.c(1);
            j.c(2);
        }

        j.c(4);
        j.c(3);
        j.c(5);
        j = null;
        return b(d1);
    }

    final void k() {
        if (fld_m_Vector.isEmpty()) {
            cn = new cls_d(this, 50, ((ci.a) >> 8) + 88, ((ci.b) >> 8) + 104);
        } else {
            cn = (cls_d) fld_m_Vector.elementAt(j(fld_m_Vector.size() - 1));
        }
    }

    final void p(int i1) {
        if (cn.r != i1) {
            for (int j1 = 0; j1 < fld_m_Vector.size(); j1++) {
                cls_d d1;
                if ((d1 = (cls_d) fld_m_Vector.elementAt(j1)).r == i1) {
                    cn = d1;
                    return;
                }
            }

        }
    }

    final void l() {
        bS = 0L;
        bT = 0L;
        bY = 0L;
        F = 0L;
        bV = 0L;
        bW = 0L;
        bU = 0L;
        bX = 0L;
        bR = 0L;
        bZ = 0L;
        ai = 0;
        aj = 0;
        ak = 0;
        G = 0;
        I = true;
        H = false;
        for (int i1 = 0; i1 < 10; i1++) {
            if (bl[i1] != null)
                bl[i1].m = 0L;
            if (bm[i1] != null)
                bm[i1].m = 0L;
            if (bn[i1] != null)
                bn[i1].m = 0L;
            if (bv[i1] != null)
                bv[i1].m = 0L;
            if (bw[i1] != null)
                bw[i1].m = 0L;
            if (bx[i1] != null)
                bx[i1].m = 0L;
            if (by[i1] != null)
                by[i1].m = 0L;
            if (bz[i1] != null)
                bz[i1].m = 0L;
            if (bA[i1] != null)
                bA[i1].m = 0L;
        }

        if (bH != null)
            bH.m = 0L;
        if (bF != null)
            bF.m = 0L;
        if (ck != null) {
            for (int j1 = 0; j1 < 12; j1++)
                ck.M[j1] = 0L;

            for (int k1 = 0; k1 < cH.length; k1++)
                cH[k1] = 0;

            ck.H &= 0xfffeffff;
            ck.k = 3;
            ck.w = false;
            ck.N = false;
            ck.Q = 0L;
            ck.R = 0L;
            ck.S = 0L;
        }
        if (dt != null) {
            for (int l1 = 0; l1 < dt.length; l1++)
                if (dt[l1] != null)
                    dt[l1].m = 0L;

        }
    }

    final void q(int i1) {
        ck = new cls_d(this, 0, 0, 0);
        a(ck, 0, 0);
        if (i1 == 2) {
            co.removeAllElements();
            cp.removeAllElements();
            recordManager.g();
        }
        recordManager.i = cA;
        this.bi = null;
    }

    final int[] r(int i1) {
        int ai1[];
        InputStream in = sporeInstance.getClass().getResourceAsStream("/0.bin");
        DataInputStream din = new DataInputStream(in);
        try {
            for (int l1 = 0; l1 < i1; l1++) {
                int j1 = din.readUnsignedByte();
                din.skipBytes(j1 * 3);
            }

            int k1;
            ai1 = new int[k1 = din.readUnsignedByte()];
            for (i1 = 0; i1 < k1; i1++) {
                int i2 = din.readUnsignedByte();
                int j2 = din.readUnsignedByte();
                int k2 = din.readUnsignedByte();
                ai1[i1] = i2 << 16 | j2 << 8 | k2;
            }

            return ai1;
        } catch (Exception ex) {
        }
        return null;
    }

    protected final void keyPressed(int i1) {
        if (i1 == -10)
            return;
        switch (i1) {
            case -6:
            case 6:
                super.keyStats |= 0x20000;
                break;

            case -7:
            case 7:
                super.keyStats |= 0x40000;
                break;

            case 48:
                super.keyStats |= 0x80;
                break;

            case 49:
                super.keyStats |= 0x100;
                break;

            case 50:
                super.keyStats |= 0x200;
                break;

            case 51:
                super.keyStats |= 0x400;
                break;

            case 52:
                super.keyStats |= 0x800;
                break;

            case 53:
                super.keyStats |= 0x1000;
                break;

            case 54:
                super.keyStats |= 0x2000;
                break;

            case 55:
                super.keyStats |= 0x4000;
                break;

            case 56:
                super.keyStats |= 0x8000;
                break;

            case 57:
                super.keyStats |= 0x10000;
                break;

            case 42:
                super.keyStats |= 0x80000;
                break;

            case 35:
                super.keyStats |= 0x100000;
                break;

            case -5:
            case -4:
            case -3:
            case -2:
            case -1:
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 8:
            case 9:
            case 10:
            case 11: // '\013'
            case 12: // '\f'
            case 13:
            case 14: // '\016'
            case 15:
            case 16:
            case 17: // '\021'
            case 18: // '\022'
            case 19: // '\023'
            case 20: // '\024'
            case 21: // '\025'
            case 22: // '\026'
            case 23: // '\027'
            case 24: // '\030'
            case 25: // '\031'
            case 26: // '\032'
            case 27:
            case 28:
            case 29:
            case 30: // '\036'
            case 31:
            case 32:
            case 33: // '!'
            case 34:
            case 36: // '$'
            case 37: // '%'
            case 38: // '&'
            case 39: // '\''
            case 40: // '('
            case 41: // ')'
            case 43:
            case 44:
            case 45:
            case 46:
            case 47:
            default:
                if (i1 == -8 || i1 == 8)
                    super.keyStats |= 0x40;
                switch (getGameAction(i1)) {
                    case 2:
                        super.keyStats |= 8;
                        break;

                    case 5:
                        super.keyStats |= 0x10;
                        break;

                    case 1:
                        super.keyStats |= 2;
                        break;

                    case 6:
                        super.keyStats |= 4;
                        break;

                    case 8:
                        super.keyStats |= 0x20;
                        break;
                }
                break;
        }
        if (aU && (super.keyStats & 0x40000) != 0) {
            super.c = true;
            a(0x40000);
        } else {
            super.c = false;
        }
    }

    protected final void keyReleased(int i1) {
        int j1 = 0;
        if (i1 == -10)
            return;
        switch (i1) {
            case -6:
            case 6:
                j1 = 0x20000;
                break;

            case -7:
            case 7:
                j1 = 0x40000;
                break;

            case 48:
                j1 = 128;
                break;

            case 49:
                j1 = 256;
                break;

            case 50:
                j1 = 512;
                break;

            case 51:
                j1 = 1024;
                break;

            case 52:
                j1 = 2048;
                break;

            case 53:
                j1 = 4096;
                break;

            case 54:
                j1 = 8192;
                break;

            case 55:
                j1 = 16384;
                break;

            case 56:
                j1 = 32768;
                break;

            case 57:
                j1 = 0x10000;
                break;

            case 42:
                j1 = 0x80000;
                break;

            case 35:
                j1 = 0x100000;
                break;

            case -5:
            case -4:
            case -3:
            case -2:
            case -1:
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 8:
            case 9:
            case 10:
            case 11: // '\013'
            case 12: // '\f'
            case 13:
            case 14: // '\016'
            case 15:
            case 16:
            case 17: // '\021'
            case 18: // '\022'
            case 19: // '\023'
            case 20: // '\024'
            case 21: // '\025'
            case 22: // '\026'
            case 23: // '\027'
            case 24: // '\030'
            case 25: // '\031'
            case 26: // '\032'
            case 27:
            case 28:
            case 29:
            case 30: // '\036'
            case 31:
            case 32:
            case 33: // '!'
            case 34:
            case 36: // '$'
            case 37: // '%'
            case 38: // '&'
            case 39: // '\''
            case 40: // '('
            case 41: // ')'
            case 43:
            case 44:
            case 45:
            case 46:
            case 47:
            default:
                if (i1 == -8 || i1 == 8)
                    j1 = 64;
                switch (getGameAction(i1)) {
                    case 2:
                        j1 = 8;
                        break;

                    case 5:
                        j1 = 16;
                        break;

                    case 1:
                        j1 = 2;
                        break;

                    case 6:
                        j1 = 4;
                        break;

                    case 8:
                        j1 = 32;
                        break;
                }
                break;
        }
        a(j1);
    }

    protected final void keyRepeated(int i1) {
    }

    protected final void hideNotify() {
        e();
        L.a();
        L.d();
        df = System.currentTimeMillis();
        aS = true;
        cW = false;
    }

    protected final void showNotify() {
        try {
            Thread.sleep(500L);
        }
        catch (Exception _ex) {
        }
        if ((gameState == 4 || gameState == 5 || gameState == 6 && R == 4) && !L.d)
            L.a(27, true);
        else if (gameState == 14 || gameState == 6 && (y.a.a == 23 || y.a.a == 12 && y.a.r == 6 || y.a.a == 24))
            L.a(26, true);
        if (gameState == 12 || gameState == 13) {
            ca += System.currentTimeMillis() - df;
            cb += System.currentTimeMillis() - df;
        }
        super.keyStats = 0;
        super.fld_e_int = 0;
        cW = true;
        if (aS) {
            aS = false;
            if (sporeInstance.myThread == null) {
                sporeInstance.myThread = new Thread(this);
                sporeInstance.myThread.start();
            }
        }
        L.b();
    }

    private int a(byte abyte0[], int i1) {
        int j1 = 0;
        for (i1--; i1 >= 0; i1--)
            j1 |= abyte0[dy++] << i1;

        return j1;
    }

    private void a(byte abyte0[], int i1, int j1) {
        for (j1--; j1 >= 0; j1--)
            abyte0[dy++] = (byte) (i1 >> j1 & 1);

    }

    final String b(cls_d d1) {
        Vector vector = d1.J;
        int i1 = d1.H;
        int j1 = d1.f;
        int k1 = d1.g;
        int id1 = d1.K;
        char ac1[] = new char[60];
        byte byte0;
        if ((i1 & 4) != 0)
            byte0 = 3;
        else if ((i1 & 2) != 0)
            byte0 = 2;
        else if ((i1 & 1) != 0)
            byte0 = 1;
        else
            byte0 = 0;
        byte byte1;
        if ((i1 & 0x20) != 0)
            byte1 = 3;
        else if ((i1 & 0x10) != 0)
            byte1 = 2;
        else if ((i1 & 8) != 0)
            byte1 = 1;
        else
            byte1 = 0;
        byte byte2;
        if ((i1 & 0x100) != 0)
            byte2 = 3;
        else if ((i1 & 0x80) != 0)
            byte2 = 2;
        else if ((i1 & 0x40) != 0)
            byte2 = 1;
        else
            byte2 = 0;
        if ((i1 & 0x800) != 0)
            i1 = 3;
        else if ((i1 & 0x400) != 0)
            i1 = 2;
        else if ((i1 & 0x200) != 0)
            i1 = 1;
        else
            i1 = 0;
        Vector vector1 = new Vector();
        if (gameState == 0)
            a();
        cls_l l1;
        switch (byte0) {
            case 3:
                vector1.addElement(new Integer(4));
                // fall through

            case 2:
                vector1.addElement(new Integer(2));
                // fall through

            case 1:
                vector1.addElement(new Integer(1));
                // fall through

            default:
                switch (byte1) {
                    case 3:
                        vector1.addElement(new Integer(32));
                        // fall through

                    case 2:
                        vector1.addElement(new Integer(16));
                        // fall through

                    case 1:
                        vector1.addElement(new Integer(8));
                        // fall through

                    default:
                        switch (byte2) {
                            case 3:
                                vector1.addElement(new Integer(256));
                                // fall through

                            case 2:
                                vector1.addElement(new Integer(128));
                                // fall through

                            case 1:
                                vector1.addElement(new Integer(64));
                                // fall through

                            default:
                                switch (i1) {
                                    case 3:
                                        vector1.addElement(new Integer(2048));
                                        // fall through

                                    case 2:
                                        vector1.addElement(new Integer(1024));
                                        // fall through

                                    case 1:
                                        vector1.addElement(new Integer(512));
                                        // fall through

                                    default:
                                        l1 = (cls_l) vector.elementAt(1);
                                        break;
                                }
                                break;
                        }
                        break;
                }
                break;
        }
        cls_l l2 = (cls_l) vector.elementAt(0);
        cls_l l3 = (cls_l) vector.elementAt(2);
        long al1[] = {
                0L, 0L, 0L, 0L, 0L
        };
        for (int i2 = 0; i2 < vector1.size(); i2++) {
            int j2 = ((Integer) vector1.elementAt(i2)).intValue();
            for (int j3 = 3; j3 < vector.size(); j3++) {
                cls_l l4;
                if ((l4 = (cls_l) vector.elementAt(j3)).d != j2)
                    continue;
                int k4 = l4.b >> 4;
                int j5;
                j5 = 0;
                while (j5 < 3 && l4.j != vector.elementAt(j5)) {
                    j5++;
                }
                al1[i2] |= (long) (1 << k4) << (j5 << 4);
            }

            if (gameState == 0)
                a();
        }

        dy = 0;
        byte abyte0[] = new byte[300];
        a(abyte0, byte0, 2);
        a(abyte0, byte1, 2);
        a(abyte0, byte2, 2);
        a(abyte0, i1, 2);
        a(abyte0, j1, 4);
        a(abyte0, k1, 4);
        a(abyte0, id1, 4);
        a(abyte0, l2.c / 5, 5);
        a(abyte0, l1.c / 5, 5);
        a(abyte0, l3.c / 5, 5);
        for (int k2 = 0; k2 < 5; k2++) {
            a(abyte0, (int) (65535L & al1[k2]), 16);
            a(abyte0, (int) (65535L & al1[k2] >> 16), 16);
            a(abyte0, (int) (65535L & al1[k2] >> 32), 16);
        }

        a(abyte0, 0xffff & l1.a, 7);
        a(abyte0, 0xffff & l3.a, 7);
        int i3 = 0;
        for (int k3 = 0; k3 < abyte0.length; k3++)
            i3 += d(abyte0[k3], k3);

        a(abyte0, 0, 1);
        a(abyte0, i3, 10);
        int i4 = 0;
        for (int j4 = 0; j4 < abyte0.length; j4 += 5) {
            int i5 = 0;
            for (int k5 = 0; k5 < 5; k5++)
                if (abyte0[j4 + (4 - k5)] == 1)
                    i5 |= 1 << k5;

            if (i5 < 10)
                ac1[i4] = (char) (i5 + 48);
            else
                ac1[i4] = (char) (65 + (i5 - 10));
            i4++;
            if (gameState == 0)
                a();
        }

        return new String(ac1);
    }

    final boolean a(cls_d d1, String s1) {
        if (s1.length() != 60)
            s1 = cA;
        int i1 = 0;
        int k1 = 0;
        byte abyte0[] = new byte[300];
        for (int k2 = 0; k2 < 60; k2++) {
            int l2 = Character.digit(s1.charAt(k2), 32);
            for (int i3 = 4; i3 >= 0; i3--) {
                abyte0[i1] = (byte) (l2 >> i3 & 1);
                if (i1 < 290)
                    k1 += d(abyte0[i1], i1);
                i1++;
            }

            if ((k2 & 1) == 0)
                a();
        }

        int ai1[][] = new int[3][5];
        int ai2[] = new int[3];
        dy = 0;
        int j3 = a(abyte0, 2);
        int is1 = a(abyte0, 2);
        i1 = a(abyte0, 2);
        int k3 = a(abyte0, 2);
        int i4 = a(abyte0, 4);
        int j4 = a(abyte0, 4);
        int k4 = a(abyte0, 4);
        for (int l4 = 0; l4 < 3; l4++)
            ai2[l4] = a(abyte0, 5);

        for (int i5 = 0; i5 < 5; i5++) {
            ai1[0][i5] = a(abyte0, 16);
            ai1[1][i5] = a(abyte0, 16);
            ai1[2][i5] = a(abyte0, 16);
        }

        int j5 = a(abyte0, 7);
        int k5 = a(abyte0, 7);
        int l5 = a(abyte0, 1);
        int i2 = a(abyte0, 10);
        if ((i2) != k1 || j3 + is1 + i1 + k3 > 5 || i4 >= 10 || j4 >= 10 || k4 >= 10 || j5 < 0 || j5 > 100 || k5 < 0 || k5 > 100 || l5 != 0)
            return false;
        Vector vector = new Vector();
        switch (j3) {
            case 3:
                vector.addElement(new Integer(4));
                // fall through

            case 2:
                vector.addElement(new Integer(2));
                // fall through

            case 1:
                vector.addElement(new Integer(1));
                // fall through

            default:
                switch (is1) {
                    case 3:
                        vector.addElement(new Integer(32));
                        // fall through

                    case 2:
                        vector.addElement(new Integer(16));
                        // fall through

                    case 1:
                        vector.addElement(new Integer(8));
                        // fall through

                    default:
                        switch (i1) {
                            case 3:
                                vector.addElement(new Integer(256));
                                // fall through

                            case 2:
                                vector.addElement(new Integer(128));
                                // fall through

                            case 1:
                                vector.addElement(new Integer(64));
                                // fall through

                            default:
                                switch (k3) {
                                    case 3:
                                        vector.addElement(new Integer(2048));
                                        // fall through

                                    case 2:
                                        vector.addElement(new Integer(1024));
                                        // fall through

                                    case 1:
                                        vector.addElement(new Integer(512));
                                        // fall through

                                    default:
                                        d1.H = 0;
                                        break;
                                }
                                break;
                        }
                        break;
                }
                break;
        }
        d1.J.removeAllElements();
        for (is1 = 0; is1 < 3; is1++) {
            cls_l l1;
            (l1 = new cls_l()).d = 16384;
            l1.a = inf_m.X[is1][0];
            l1.b = inf_m.X[is1][1];
            l1.c = ai2[is1] * 5;
            if (is1 > 0)
                l1.j = (cls_l) d1.J.firstElement();
            d1.J.addElement(l1);
            a();
        }

        d1.L[0] = (cls_l) d1.J.elementAt(1);
        d1.L[1] = (cls_l) d1.J.elementAt(0);
        d1.L[2] = (cls_l) d1.J.elementAt(2);
        d1.L[0].a = j5;
        d1.L[2].a = k5;
        for (is1 = 0; is1 < 3; is1++) {
            for (int j1 = 0; j1 < vector.size(); j1++) {
                for (int j2 = 0; j2 < 16; j2++)
                    if ((ai1[is1][j1] >> j2 & 1) != 0) {
                        cls_l l3;
                        (l3 = new cls_l()).d = ((Integer) vector.elementAt(j1)).intValue();
                        l3.b = j2 << 4;
                        l3.j = (cls_l) d1.J.elementAt(is1);
                        d1.J.addElement(l3);
                        d1.H |= l3.d;
                    }

            }

            a();
        }

        d1.f = i4;
        d1.g = j4;
        d1.K = k4;
        if ((d1.H & 0x40) != 0) {
            char c1 = '\u014C';
            d1.e = c1 * (/*s1 = */d1.U[0]) >> 8;
        } else {
            d1.e = d1.U[0];
        }
        if (d1.s == 18 && (d1.H & 0x80) != 0)
            d1.A <<= 1;
        a(d1, 1, 0);
        d1.d();
        d1.a();
        return true;
    }

    final boolean s(int i1) {
        i1 = Integer.parseInt(y.b[8].x[0][i1]);
        for (int j1 = 0; j1 < cq.size(); j1++)
            if (Integer.parseInt((String) cq.elementAt(j1)) == i1)
                return true;

        return false;
    }

    public static void a(Graphics g1, int i1, int j1, int k1) {
        g1.drawArc(i1 - k1, j1 - k1, k1 << 1, k1 << 1, 0, 360);
    }

    public static void b(Graphics g1, int i1, int j1, int k1) {
        g1.fillArc(i1 - k1, j1 - k1, k1 << 1, k1 << 1, 0, 360);
    }

    private static boolean isSupportLanguage(String s1) {
        if (s1 == null)
            return false;
        return s1.equals("en") || s1.equals("fr") || s1.equals("it") || s1.equals("de") || s1.equals("es") || s1.equals("menu");
    }

    public final void m() {
        if (fld_m_Vector.isEmpty()) {
            k();
            dh = new cls_d[2];
            for (int i1 = 0; i1 < 2; i1++) {
//                int l1;
                int j1 = (5 * g(i1 << 7)) >> 8;
                int k1 = (5 * f(i1 << 7)) >> 8;
                cls_d d1;
                (d1 = new cls_d(this, 1, ((ci.a) >> 8) + 88 + j1, ((ci.b) >> 8) + 130 + k1)).f = i1;
                d1.d = d1.e << 2;
                d1.fld_m_int = d1.l = 0xff & (i1 << 7) - 64;
                fld_m_Vector.addElement(d1);
                dh[i1] = d1;
            }

        }
    }

    public final void n() {
        if (dh != null) {
            for (int i1 = 0; i1 < 2; i1++)
                fld_m_Vector.removeElement(dh[i1]);

            dh = null;
        }
    }

    public final void o() {
        dB = 1;
        dA = 0;
        dC = false;
    }
}